package projek_akhir;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Scanner;
public class Projek_akhir {
public static void main(String[] args) throws IOException {
System.out.println("=========================================");
System.out.println("\tALGORITMA DAN PEMROGRAMAN");
System.out.println("=========================================");
String user,pass,coba;
Scanner input = new Scanner(System.in);
//Masukkan pilihan menu
int pilih;
String biodata,kalku,data,kamus,pilihmenu[]={"","Aplikasi Input Biodata",
"Aplikasi Kalkulator","Aplikasi Menghitung Luas","Aplikasi Pencarian Data",
"Aplikasi Kamus Sederhana"};
MASUK:
do{
System.out.println("\nPilihan Menu :");
System.out.println("1.Aplikasi Input Biodata");
System.out.println("2.Aplikasi Kalkulator");
System.out.println("3.Aplikasi Menghitung Luas");
System.out.println("4.Aplikasi Pencarian Data");
System.out.println("5.Aplikasi Kamus Sederhana");
System.out.println("6.Keluar");
do{ System.out.print("\nMasukkan Pilihan Menu(1-6):");
Scanner menu = new Scanner(System.in);
pilih=menu.nextInt();
}while (pilih<1||pilih>6);
if(pilih==6)
{ System.out.println("\n==========================================");
System.out.println("\tT E R I M A K A S I H");
System.out.println("==========================================");}
//aplikasi input biodata
switch(pilih){
case 1:
do{
System.out.println("\n=====================================");
System.out.println("\t"+pilihmenu[pilih]);
System.out.println("=====================================");
Scanner msk = new Scanner(System.in);
String nama,nim,kelas,alamat;
System.out.print("Masukkan Nama\t: ");
nama=msk.nextLine();
System.out.print("Masukkan NIM\t: ");
nim=msk.nextLine();
System.out.print("Masukkan Kelas\t: ");
kelas=msk.nextLine();
System.out.print("Masukkan Alamat\t: ");
alamat=msk.nextLine();
System.out.println("\nNama\t: "+nama);
System.out.println("NIM\t: "+nim);
System.out.println("Kelas\t: "+kelas);
System.out.println("Alamat\t: "+alamat);
do{
System.out.print("\nInput Biodata Lagi(y/t)?");
biodata=msk.nextLine();
}while(!"y".equalsIgnoreCase(biodata)&&!"t".equalsIgnoreCase(biodata));
if("t".equalsIgnoreCase(biodata)) continue MASUK;
}while("y".equalsIgnoreCase(biodata));
break;
//aplikasi kalkulator
case 2:
do{
double nil1=0,nil2=0,hasil=0;
char operator;
System.out.println("\n====================================");
System.out.println("\t"+pilihmenu[pilih]);
System.out.println("====================================");
Scanner a = new Scanner(System.in);
System.out.print("Bilangan 1 = ");
nil1=a.nextDouble();
System.out.print("Bilangan 2 = ");
nil2=a.nextDouble();
DataInputStream op=new DataInputStream(System.in);
System.out.print("Operasi (+/-/*/:)= ");
operator=(char)op.read();
if(operator=='+')
hasil=nil1+nil2;
if(operator=='-')
hasil=nil1-nil2;
if(operator=='*')
hasil=nil1*nil2;
if(operator==':')
hasil=nil1/nil2;
System.out.println("Hasil\t= "+hasil);
do{
System.out.print("\nHitung Lagi(y/t)?");
kalku=a.nextLine();
}while(!"y".equalsIgnoreCase(kalku)&&!"t".equalsIgnoreCase(kalku));
if("t".equalsIgnoreCase(kalku)) continue MASUK;
}while("y".equalsIgnoreCase(kalku));
break;
//aplikasi menghitung luas
case 3:
String lagi;
double pilihluas,alas,tinggi,lsgtg,panjang,lebar,lprsg,jari,lingk;
System.out.println("\n=======================================");
System.out.println("\t"+pilihmenu[pilih]);
System.out.println("=======================================");
Scanner b = new Scanner(System.in);
LUAS:
do{
System.out.println("\nPilihan Luas:");
System.out.println("1.Luas Segitiga");
System.out.println("2.Luas Persegi Panjang");
System.out.println("3.Luas Lingkaran");
System.out.println("4.Keluar");
System.out.print("\nMasukkan Pilihan Luas (1-4) :");
pilihluas=b.nextInt();
if (pilihluas==1){
do{
System.out.println("\nLuas Segitiga");
System.out.print("Alas\t = ");
alas=b.nextInt();
System.out.print("Tinggi\t = ");
tinggi=b.nextInt();
lsgtg=alas*tinggi/2;
System.out.println("Luas Segitiga = "+lsgtg);
do{
System.out.print("\nHitung Lagi(y/t)?");
lagi=b.nextLine();
}while(!"y".equalsIgnoreCase(lagi)&&!"t".equalsIgnoreCase(lagi));
if("t".equalsIgnoreCase(lagi))continue LUAS;
}while("y".equalsIgnoreCase(lagi));
}
if (pilihluas==2){
do{
System.out.println("\nLuas Persegi Panjang");
System.out.print("Panjang\t = ");
panjang=b.nextInt();
System.out.print("Lebar\t = ");
lebar=b.nextInt();
lprsg=panjang*lebar;
System.out.println("Luas Persegi Panjang = "+lprsg);
do{
System.out.print("\nHitung Lagi(y/t)?");
lagi=b.nextLine();
}while(!"y".equalsIgnoreCase(lagi)&&!"t".equalsIgnoreCase(lagi));
if("t".equalsIgnoreCase(lagi)){continue LUAS;}
}while("y".equalsIgnoreCase(lagi));
}
if (pilihluas==3){
do{
System.out.println("\nLuas Lingkaran");
System.out.print("Jari-jari = ");
jari=b.nextDouble();
lingk=3.14*jari*jari;
System.out.println("Luas Lingkaran = "+lingk);
do{
System.out.print("\nHitung Lagi(y/t)?");
lagi=b.nextLine();
}while(!"y".equalsIgnoreCase(lagi)&&!"t".equalsIgnoreCase(lagi));
}while("y".equalsIgnoreCase(lagi));
if("t".equalsIgnoreCase(lagi)){continue LUAS;}
}
if(pilihluas==4) continue MASUK;
}while(pilih==3);
break;
//aplikasi pencarian data
case 4:
do{
System.out.println("\n======================================");
System.out.println("\t"+pilihmenu[pilih]);
System.out.println("======================================");
Scanner c = new Scanner(System.in);
do{
System.out.print("\nCari Data Lagi(y/t)?");
data=c.nextLine();
}while(!"y".equalsIgnoreCase(data)&&!"t".equalsIgnoreCase(data));
if("t".equalsIgnoreCase(data)) continue MASUK;
}while("y".equalsIgnoreCase(data));
break;
// Aplikasi kamus sederhana
case 5:
System.out.println("\n=======================================");
System.out.println("\t"+pilihmenu[pilih]);
System.out.println("=======================================");
do{
Scanner d = new Scanner(System.in);
Scanner in = new Scanner(System.in);
String[][] kata={
{"EAT","MAKAN"},{"SLEEP","TIDUR"},{"SWIM","BERENANG"},
{"RUN","LARI"},{"GO","PERGI"},
};
String katadicari;
System.out.print("\nMASUKAN KATA = ");
katadicari=in.nextLine();
int i,k; k=-1;
for(i=0;i<5;i++)
{
if(kata[i][0].equals(katadicari.toUpperCase()))
{
k=i;
}
}
if(k==-1)
{
System.out.print("Kata '"+katadicari+ "' Tidak Ditemukan\n ");
}
else
{
System.out.println("TERJEMAHAN = "+kata[k][1]);
}
do{
System.out.print("\nTerjemahkan Lagi(y/t)?");
kamus=d.nextLine();
}while(!"y".equalsIgnoreCase(kamus)&&!"t".equalsIgnoreCase(kamus));
if("t".equalsIgnoreCase(kamus)) continue MASUK;
}while("y".equalsIgnoreCase(kamus));
break;
default:
System.out.println("nothing");
}
}while(pilih>=1&&pilih<=5);
}
}
Tidak ada komentar:
Posting Komentar