Dipahami ya..., terserah kalian pilih mau bobot berapa, tergantung kalian mau dapat nilai berapa...
--------------------------------------BOBOT 70------------------------------------------------
import java.util.Scanner;
public class menu_operasi{
public static void main(String []args){
Scanner input=new Scanner(System.in);
int pilih;
double a,b,c;
System.out.println();
System.out.println("MENU Operasi");
System.out.println("============");
System.out.println("1. Tambah");
System.out.println("2. Kurang");
System.out.println("3. Kali");
System.out.println("4. Bagi");
System.out.println("5. Keluar");
System.out.println("============");
System.out.print("Masukkan pilihan : ");
pilih = input.nextInt();
System.out.println();
switch(pilih){
case 1:
System.out.println( "Operasi Tambah" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
System.out.println("Hasil dari "+a+" + "+b+" = "+(a+b));
break;
case 2:
System.out.println( "Operasi Kurang" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
System.out.println("Hasil dari "+a+" - "+b+" = "+(a-b));
break;
case 3:
System.out.println( "Operasi Kali" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
System.out.println("Hasil dari "+a+" * "+b+" = "+(a*b));
break;
case 4:
System.out.println( "Operasi Bagi" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
c = a/b;
System.out.println("Hasil dari "+a+" : "+b+" = "+(c));
break;
default:
System.out.println("Pilihan yang anda masukkan salah.");
}
}
}
public static void main(String []args){
Scanner input=new Scanner(System.in);
int pilih;
double a,b,c;
System.out.println();
System.out.println("MENU Operasi");
System.out.println("============");
System.out.println("1. Tambah");
System.out.println("2. Kurang");
System.out.println("3. Kali");
System.out.println("4. Bagi");
System.out.println("5. Keluar");
System.out.println("============");
System.out.print("Masukkan pilihan : ");
pilih = input.nextInt();
System.out.println();
switch(pilih){
case 1:
System.out.println( "Operasi Tambah" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
System.out.println("Hasil dari "+a+" + "+b+" = "+(a+b));
break;
case 2:
System.out.println( "Operasi Kurang" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
System.out.println("Hasil dari "+a+" - "+b+" = "+(a-b));
break;
case 3:
System.out.println( "Operasi Kali" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
System.out.println("Hasil dari "+a+" * "+b+" = "+(a*b));
break;
case 4:
System.out.println( "Operasi Bagi" );
System.out.print("Masukkan nilai pertama : ");
a = input.nextInt();
System.out.print("Masukkan nilai kedua : ");
b = input.nextInt();
c = a/b;
System.out.println("Hasil dari "+a+" : "+b+" = "+(c));
break;
default:
System.out.println("Pilihan yang anda masukkan salah.");
}
}
}
--------------------------------------BOBOT 80------------------------------------------------
import java.util.Scanner;
public class Kfull1
{
{
public static void main(String args[])
{
Scanner scanner = new Scanner(System.in);
int i;
do
{
System.out.println("============= MENU ===============");
System.out.println("1. Anak Ayam");
System.out.println("2. Segitiga");
System.out.println("3. Keluar");
System.out.println("==================================");
System.out.print("Pilih Menu: ");
i = scanner.nextInt();
switch(i)
{
case 1: //
System.out.print("Berapa jumlah anak ayam? ");
int j = scanner.nextInt();
System.out.print("\n");
for(int l = 1; l <= j; l++){
System.out.println("Anak ayam mati "+l+" ,sisa "+ (j-l));
}
break;
{
Scanner scanner = new Scanner(System.in);
int i;
do
{
System.out.println("============= MENU ===============");
System.out.println("1. Anak Ayam");
System.out.println("2. Segitiga");
System.out.println("3. Keluar");
System.out.println("==================================");
System.out.print("Pilih Menu: ");
i = scanner.nextInt();
switch(i)
{
case 1: //
System.out.print("Berapa jumlah anak ayam? ");
int j = scanner.nextInt();
System.out.print("\n");
for(int l = 1; l <= j; l++){
System.out.println("Anak ayam mati "+l+" ,sisa "+ (j-l));
}
break;
case 2: // '\002'
int k = 10;
System.out.print("\n");
int i1 = 1;
do
{
if(i1 > 10)
break ;
for(int j1 = 1; j1 <= k; j1++)
System.out.print(" ");
int k = 10;
System.out.print("\n");
int i1 = 1;
do
{
if(i1 > 10)
break ;
for(int j1 = 1; j1 <= k; j1++)
System.out.print(" ");
k--;
for(int k1 = 1; k1 <= i1; k1++)
System.out.print("* ");
for(int k1 = 1; k1 <= i1; k1++)
System.out.print("* ");
System.out.print("\n");
i1++;
} while(true);
i1++;
} while(true);
case 3: // '\003'
System.exit(0);
// fall through
System.exit(0);
// fall through
default:
System.out.println("Maaf, menu tidak tersedia.");
break;
}
System.out.println("\n");
} while(i != 3);
}
}
System.out.println("Maaf, menu tidak tersedia.");
break;
}
System.out.println("\n");
} while(i != 3);
}
}
--------------------------------------BOBOT 90------------------------------------------------
import java.util.Scanner;
public class nilai_mhs {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int i,jumlahMk;
String nama,npm,jurusan;
String mataKuliah[]=new String[15];
String grade[]=new String[15];
int uts[]=new int[15];
int uas[]=new int[15];
double nilai[]=new double[15];
System.out.println("==================================");
System.out.println(" Menghitung Nilai Mahasiswa");
System.out.println("==================================");
System.out.print(" Masukan Jumlah Mata Kuliah: ");
jumlahMk=input.nextInt();
System.out.println("==================================");
System.out.print(" Nama : ");
nama=input.next();
System.out.print(" NPM : ");
npm=input.next();
System.out.print(" Jurusan : ");
jurusan=input.next();
System.out.println("==================================");
for(i=1; i<=jumlahMk; i++){
System.out.print("\n Mata kuliah ke-"+i+" : ");
mataKuliah[i]=input.next();
System.out.print(" Nilai UTS : ");
uts[i]=input.nextInt();
System.out.print(" Nilai UAS : ");
uas[i]=input.nextInt();
nilai[i]=((uts[i]*0.7)+(uas[i]*0.3));
if (nilai[i]>=85) grade[i]="A";
else if (nilai[i]>=75) grade[i]="B";
else if (nilai[i]>=65) grade[i]="C";
else if (nilai[i]>=50) grade[i]="D";
else grade[i]="E";
}
System.out.println("\n==================================");
System.out.println("\n\n Nama: "+nama+" NPM: "+npm);
System.out.println("=========================================");
System.out.println(" Mata Kuliah Nilai Grade");
System.out.println("=========================================");
for(i=1;i<=jumlahMk;i++){
System.out.println(" "+mataKuliah[i]+" "+nilai[i]+" "+grade[i]);
}
System.out.println("\n\n=============================================");
System.out.println(" Terima Kasih Telah Menggunakan Program Kami");
System.out.println("=============================================");
System.exit(0);
}
}
public class nilai_mhs {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int i,jumlahMk;
String nama,npm,jurusan;
String mataKuliah[]=new String[15];
String grade[]=new String[15];
int uts[]=new int[15];
int uas[]=new int[15];
double nilai[]=new double[15];
System.out.println("==================================");
System.out.println(" Menghitung Nilai Mahasiswa");
System.out.println("==================================");
System.out.print(" Masukan Jumlah Mata Kuliah: ");
jumlahMk=input.nextInt();
System.out.println("==================================");
System.out.print(" Nama : ");
nama=input.next();
System.out.print(" NPM : ");
npm=input.next();
System.out.print(" Jurusan : ");
jurusan=input.next();
System.out.println("==================================");
for(i=1; i<=jumlahMk; i++){
System.out.print("\n Mata kuliah ke-"+i+" : ");
mataKuliah[i]=input.next();
System.out.print(" Nilai UTS : ");
uts[i]=input.nextInt();
System.out.print(" Nilai UAS : ");
uas[i]=input.nextInt();
nilai[i]=((uts[i]*0.7)+(uas[i]*0.3));
if (nilai[i]>=85) grade[i]="A";
else if (nilai[i]>=75) grade[i]="B";
else if (nilai[i]>=65) grade[i]="C";
else if (nilai[i]>=50) grade[i]="D";
else grade[i]="E";
}
System.out.println("\n==================================");
System.out.println("\n\n Nama: "+nama+" NPM: "+npm);
System.out.println("=========================================");
System.out.println(" Mata Kuliah Nilai Grade");
System.out.println("=========================================");
for(i=1;i<=jumlahMk;i++){
System.out.println(" "+mataKuliah[i]+" "+nilai[i]+" "+grade[i]);
}
System.out.println("\n\n=============================================");
System.out.println(" Terima Kasih Telah Menggunakan Program Kami");
System.out.println("=============================================");
System.exit(0);
}
}
--------------------------------------BOBOT 100------------------------------------------------
import java.util.Scanner;
class tugas2
{int bil,bil2,i,ganjil,genap,fak,t;
int k = 1;
//method bilangan ganjil
public void tampilganjil(){
for(int i=1;i<=ganjil;i++){
if(i%2==1 )
System.out.print(i+" ");
class tugas2
{int bil,bil2,i,ganjil,genap,fak,t;
int k = 1;
//method bilangan ganjil
public void tampilganjil(){
for(int i=1;i<=ganjil;i++){
if(i%2==1 )
System.out.print(i+" ");
}
}
//method bilangan genap
public void tampilgenap(){
}
//method bilangan genap
public void tampilgenap(){
for(int i=2;i<=genap;i++){
if(i%2==0 )
if(i%2==0 )
System.out.print(i+" ");
}
}
//method bilangan faktorial
}
}
//method bilangan faktorial
public void tampilfak(){
System.out.print(fak+"!= ");
for (i=fak; i>=1; i--){
System.out.print(i);
if (i>1)
System.out.print("x");
System.out.print(fak+"!= ");
for (i=fak; i>=1; i--){
System.out.print(i);
if (i>1)
System.out.print("x");
k=k*i;}
System.out.println ("="+k);
System.out.println ("="+k);
}
//method menampilkan segitiga
public void segitiga1() {
System.out.println("");
for(int i=1; i<=t; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println("");
}
}
//method menu utama
public void segitiga1() {
System.out.println("");
for(int i=1; i<=t; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print("*");
}
System.out.println("");
}
}
//method menu utama
public void tampilmenu(){
System.out.println("");
System.out.println(" MENU ");
System.out.println(" ====================================");
System.out.println(" 1. Menampilkan Bilangan Ganjil ");
System.out.println(" 2. Menampilkan Bilangan Genap ");
System.out.println(" 3. Menampilkan Bilangan Faktorial ");
System.out.println(" 4. Menampilkan segitiga siku-siku ");
System.out.println(" 5. Keluar ");
System.out.println(" ====================================");
System.out.println(" ");
System.out.println("");
System.out.println(" MENU ");
System.out.println(" ====================================");
System.out.println(" 1. Menampilkan Bilangan Ganjil ");
System.out.println(" 2. Menampilkan Bilangan Genap ");
System.out.println(" 3. Menampilkan Bilangan Faktorial ");
System.out.println(" 4. Menampilkan segitiga siku-siku ");
System.out.println(" 5. Keluar ");
System.out.println(" ====================================");
System.out.println(" ");
}
public static void main(String[] args)
{
tugas2 obj = new tugas2 ();
for (int n = 1;n>0 ;n++ ) //melakukan perulangan sebanyak tak terhingga
{Scanner input = new Scanner(System.in);
obj.tampilmenu();
System.out.print("Masukkan Angka dari Menu diatas : ");
obj.bil = input.nextInt();
{
tugas2 obj = new tugas2 ();
for (int n = 1;n>0 ;n++ ) //melakukan perulangan sebanyak tak terhingga
{Scanner input = new Scanner(System.in);
obj.tampilmenu();
System.out.print("Masukkan Angka dari Menu diatas : ");
obj.bil = input.nextInt();
if (obj.bil==1) // menampilkan bilangan ganjil jika input = 1
{
System.out.println(" ");
System.out.println(" ");
System.out.println("*MENAMPILKAN BILANGAN GANJIL*");
System.out.print("masukkan angka: ");
obj.ganjil = input.nextInt();
System.out.print("Bilangan ganjil: ");
obj.tampilganjil(); // memanggil method bilangan ganjil
System.out.println(" ");
System.out.println(" ");
{
System.out.println(" ");
System.out.println(" ");
System.out.println("*MENAMPILKAN BILANGAN GANJIL*");
System.out.print("masukkan angka: ");
obj.ganjil = input.nextInt();
System.out.print("Bilangan ganjil: ");
obj.tampilganjil(); // memanggil method bilangan ganjil
System.out.println(" ");
System.out.println(" ");
}else if (obj.bil==2) // menampilkan bil genap jika inputnya 2
{ System.out.println(" ");
System.out.println(" ");
//System.out.print("Masukkan Angka dari Menu diatas : ");
System.out.println("*MENAMPILKAN BILANGAN GENAP*");
System.out.print("masukkan angka: ");
obj.genap = input.nextInt();
System.out.print("Bilangan genap: ");
obj.tampilgenap(); // memanggil method bilangan genap
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
//System.out.print("Masukkan Angka dari Menu diatas : ");
System.out.println("*MENAMPILKAN BILANGAN GENAP*");
System.out.print("masukkan angka: ");
obj.genap = input.nextInt();
System.out.print("Bilangan genap: ");
obj.tampilgenap(); // memanggil method bilangan genap
System.out.println(" ");
System.out.println(" ");
}else if (obj.bil==3) //menampilkan hasil faktorial jika inputannya 3
{ System.out.println(" ");
System.out.println(" ");
//System.out.print("Masukkan Angka dari Menu diatas : ");
System.out.println("*MENAMPILKAN HASIL FAKTORIAL*");
System.out.print("masukkan angka: ");
obj.fak = input.nextInt();
obj.tampilfak(); // memanggil method faktorial
System.out.println(" ");
{ System.out.println(" ");
System.out.println(" ");
//System.out.print("Masukkan Angka dari Menu diatas : ");
System.out.println("*MENAMPILKAN HASIL FAKTORIAL*");
System.out.print("masukkan angka: ");
obj.fak = input.nextInt();
obj.tampilfak(); // memanggil method faktorial
System.out.println(" ");
}else if (obj.bil==4) // menampilkan bil genap jika inputnya 2
{ System.out.println(" ");
System.out.println(" ");
//System.out.print("Masukkan Angka dari Menu diatas : ");
System.out.println("*MENAMPILKAN SEGITIGA SIKU-SIKU*");
System.out.print("Masukkan jumlah tinggi yang diinginkan : ");
obj.t= input.nextInt();
obj.segitiga1();
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
//System.out.print("Masukkan Angka dari Menu diatas : ");
System.out.println("*MENAMPILKAN SEGITIGA SIKU-SIKU*");
System.out.print("Masukkan jumlah tinggi yang diinginkan : ");
obj.t= input.nextInt();
obj.segitiga1();
System.out.println(" ");
System.out.println(" ");
}else if (obj.bil==5)
{ System.exit(0);
}else{
System.out.println(" ");
System.out.println("Input Invalid !"); // menampilkan pesan invalid jika inputan selain nomor yang ada di MENU
System.out.println(" ");
System.out.println("Input Invalid !"); // menampilkan pesan invalid jika inputan selain nomor yang ada di MENU
}
}
}
}
}
Tidak ada komentar:
Posting Komentar