Program
ke -1
import
java.util.Scanner;
public
class nilaiA
{
public static void main(String args[])
{
Scanner masuk=new
Scanner(System.in);
int pil;
float p,l,a,t,r,lp,kp,ls,ks,ll,kl;
System.out.print("Masukkan
Pilihan = ");
pil = masuk.nextInt();
switch (pil){
case
1:System.out.println("Hitung & Kel Persegi Panjang");
System.out.print("Masukkan
Panjang = ");
p=masuk.nextFloat();
System.out.print("Masukkan
Lebar = ");
l=masuk.nextFloat();
lp = p * l;
kp = (p+l) *2;
System.out.println("Luas
Persegi Panjang = "+lp);
System.out.println("Keliling
Persegi Panjang = "+kp);
break;
case
2:System.out.println("Hitung Luas & Keliling SegiTiga");
System.out.print("Masukkan
Alas = ");
a=masuk.nextFloat();
System.out.print("Masukkan
Tinggi = ");
t=masuk.nextFloat();
ls=0.5f*a*t;
ks=a+a+a;
System.out.println("Luas
SegiTiga = "+ls);
System.out.println("Keliling
SegiTiga = "+ks);
break;
case
3:System.out.println("Hitung Luas & Keliling Lingkaran");
System.out.print("Masukkan
Jari-jari = ");
r=masuk.nextFloat();
ll= 3.14f * r * r;
kl= 3.14f*r*2;
System.out.println("Luas
Lingkaran = "+ll);
System.out.println("Keliling
Lingkaran = "+kl);
break;
default: System.out.println("Pilihan
Salah!!!");break;}
}
}
|
Hasil
:
Program
ke -2
import
java.util.Scanner;
public
class CaseJurusan
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int pil;
System.out.print("Masukkan
pilihan = ");
pil = masuk.nextInt();
switch (pil){
case
1:System.out.println("Jurusan MI/D3");break;
case
2:System.out.println("Jurusan TK/D3");break;
case
3:System.out.println("Jurusan KA/D3");break;
case
4:System.out.println("Jurusan TI/S1");break;
case
5:System.out.println("Jurusan SI/S1");break;
default: System.out.println("Pilihan
Salah!!!");break;}
}
}
|
Hasil
: