0% found this document useful (0 votes)
64 views5 pages

Tugas Java Pertemuan 5

The document contains code for 3 Java programs written by Vincentius Sharon Excelli Lauder, a student with NPM 57418241 in the 1IA03 class. The first program checks if a user-inputted number is even or odd. The second program displays a menu of food items from a fictional "McCihuy" restaurant and prints the user's selection. The third program calculates the total price of a milk purchase based on brand, quantity, and size selected by the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views5 pages

Tugas Java Pertemuan 5

The document contains code for 3 Java programs written by Vincentius Sharon Excelli Lauder, a student with NPM 57418241 in the 1IA03 class. The first program checks if a user-inputted number is even or odd. The second program displays a menu of food items from a fictional "McCihuy" restaurant and prints the user's selection. The third program calculates the total price of a milk purchase based on brand, quantity, and size selected by the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Tugas Pertemuan 5 JAVA

Nama = Vincentius Sharon Excelli Lauder


NPM = 57418241
Kelas = 1IA03

Nomor 1

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Sharon_Excelli
*/
import java.util.Scanner;
public class Nomor1Bilangan_Genap_Ganjil {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int nilai;
Scanner input=new Scanner(System.in);
System.out.print("Masukkan Nilai Bilangan Bulat = ");
//masukan angka di output contoh "6" maka hasilnya akan bilangan genap dan bisa dibagi 2
//jika memasukkan angka ganjil hasilnya akan bilangan ganjil dan tidak habis dibagi 2
nilai=input.nextInt();
if((nilai%2)==0){
System.out.println("Nilai "+nilai+" Habis Dibagi 2");
System.out.println("Maka nilai ini termasuk bilangan GENAP");
}
else if(nilai%2!=0){
System.out.println("Nilai "+nilai+" Tidak Habis Dibagi 2");
System.out.println("Maka nilai ini termasuk bilangan Ganjil");
}
}
}

Nomor 2

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Sharon_Excellii
*/
import java.util.Scanner;
public class Nomor2Menu_Restaurant_McCihuy {
public static void main (String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Menu Restaurant Mc`Cihuy");
System.out.println("=======================================");
System.out.println("1. Nasi Goreng Informatika Rp. 5.000,-");
System.out.println("2. Nasi Soto Ayam Internet Rp. 7.000,-");
System.out.println("3. Gado-gado Disket Rp. 4.500,-");
System.out.println("4. Bubur Ayam LAN Rp. 4.000,-");
System.out.println("=======================================");
System.out.print("Masukkan Pilihan Anda 1-4 = ");//masukan pilihan di outputnya
int pilih=input.nextInt();
switch (pilih){
case 1:
System.out.println("Pilihan No.1 Nasi Goreng Informatika Rp. 5.000,-");
break;
case 2:
System.out.println("Pilihan No.2 Nasi Soto Ayam Internet Rp. 7.000,-");
break;
case 3:
System.out.println("Pilihan No.3 Gado-gado Disket Rp. 4.500,-");
break;
case 4:
System.out.println("Pilihan No.4 Bubur Ayam LAN Rp. 4.000,-");
break;
default:
System.out.println("Pilihan Tidak Tersedia!!!!");
break;
}
}
}

Nomor 3

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Sharon_Excelli
*/
import java.util.Scanner;
public class Nomor3Perusahaan_susu_cap_nona {
public static void main(String[] args){
int kode,jumlah;
String ukuran;
Scanner input=new Scanner(System.in);
System.out.print("Masukkan Kode Susu (1. Dancow 2. Indomilk 3. Sustacal) = ");
kode=input.nextInt();
System.out.print("masukkan Jumlah Pembelian = ");
jumlah=input.nextInt();
System.out.print("Masukkan Ukuran (B (Besar)/S (Sedang)/K(Kecil)) = ");
ukuran=input.next();
switch(kode){
case 1://Dancow
switch (ukuran){
case "B"://Besar
int DB=10000;//Dancow ukuran besar harganya 10000
int JpembelianDB=DB*jumlah;
System.out.println("Susu Dancow Ukuran Besar");
System.out.println("Harga Susu Dancow Rp. 10.000,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianDB);
break;
case "S"://Sedang
int DS=4250;//Dancow ukuran sedang harganya 4250
int JpembelianDS=DS*jumlah;
System.out.println("Susu Dancow Ukuran Sedang");
System.out.println("Harga Susu Dancow Rp. 4.250,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianDS);
break;
case "K"://Kecil
int DK=2100;//Dancow ukuran kecil harganya 2100
int JpembelianDK=DK*jumlah;
System.out.println("Susu Dancow Ukuran Kecil");
System.out.println("Harga Susu Dancow Rp. 2.100,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianDK);
break;

}
case 2://Indomilk
switch (ukuran){
case "B"://Besar
int IB=8500;//Indomilk ukuran besar harganya 8500
int JpembelianIB=IB*jumlah;
System.out.println("Susu Indomilk Ukuran Besar");
System.out.println("Harga Susu Indomilk Rp. 8.500,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianIB);
break;
case "S"://Sedang
int IS=4250;//Indomilk ukuran sedang harganya 4000
int JpembelianIS=IS*jumlah;
System.out.println("Susu Indomilk Ukuran Sedang");
System.out.println("Harga Susu Indomilk Rp. 4.000,-");
System.out.println("Jumlah Pembelian Rp."+JpembelianIS);
break;
case "K"://kecil
int IK=2025;//Indomilk ukuran kecil harganya 2025
int JpembelianIK=IK*jumlah;
System.out.println("Susu Indomilk Ukuran Kecil");
System.out.println("Harga Susu Indomilk Rp. 2.025,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianIK);
break;

}
case 3://Sustacal
switch (ukuran){
case "B"://Besar
int SB=17000;//Sustacal ukuram besar harganya 17000
int JpembelianSB=SB*jumlah;
System.out.println("Sustacal Ukuran Besar");
System.out.println("Harga Sustacal Rp. 17.000,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianSB);
break;
case "S"://Sedang
int SS=14500;//Sustacal ukuran sedangnya harganya 14500
int JpembelianSS=SS*jumlah;
System.out.println("Sustacal Ukuran Sedang");
System.out.println("Harga Sustacal Rp. 14.500,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianSS);
break;
case "K"://Kecil
int SK=8300;//Sustacal ukuran kecilnya harganya 8300
int JpembelianSK=SK*jumlah;
System.out.println("Sustacal Ukuran Kecil");
System.out.println("Harga Sustacal Rp. 8.300,-");
System.out.println("Jumlah Pembelian Rp. "+JpembelianSK);
break;

}
}
}

You might also like