Codingan dan Hasil Program Switch & Case Pemrograman
Silahkan bagi yang membutuhkan disini kita saling berbagi.
Semoga bermanfaat codingan berikut.
SALAM WONOGIRI
SALAM SUKSES
SALAM NYAWIJI
package Sekul.Rawon;
import java.util.Scanner;
public class SekulRawon {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int menu = 0,kalkulator,luas,array,pilih;
System.out.println("SALAM NYAWIJI WONOGIRI");
System.out.println("SEKUL RAWON");
System.out.println("(SEKUmpuLan Rencang Asli WONogiri)\n\n");
System.out.println("============================================");
System.out.println("Desain By Agung Saputro");
System.out.println("IG : @AgungSaputro79");
System.out.println("============================================");
while(menu==0) {
System.out.println("############################################");
System.out.println("Menu Pilihan : ");
System.out.println("1. Kalkulator");
System.out.println("2. Menghitung Luas");
System.out.println("3. Mencari Nilai Max & Min");
System.out.println("4. Exit ");
System.out.println("############################################");
System.out.print("Masukkan Pilihan Anda = ");
pilih = in.nextInt();
switch (pilih){
case 1 :
int a,b,hasil;
System.out.println("\nAnda Memilih Kalkulator");
System.out.print("Masukkan Nilai 1 : ");
Scanner scan = new Scanner(System.in);
a = scan.nextInt();
System.out.print("Masukkan Nilai 2 : ");
Scanner scan1 = new Scanner(System.in);
b = scan1.nextInt();
System.out.println(" ");
System.out.print("Hasil Penjumlahan "+a+" + "+b+" = ");
System.out.println(a+b);
System.out.print("Hasil Pengurangan "+a+" - "+b+" = ");
System.out.println(a-b);
System.out.print("Hasil Perkalian "+a+" * "+b+" = ");
System.out.println(a*b);
System.out.print("Hasil Pembagian "+a+" / "+b+" = ");
System.out.println(a/b);
System.out.println();
break;
case 2 :
int alas;
int tinggi;
int jari_jari;
double luas_segitiga;
double luas_lingkaran;
double luas_bola;
Scanner s;
System.out.println("\nAnda Memilih Menghitung Luas");
System.out.println("a. Luas Lingkaran");
s = new Scanner(System.in);
System.out.print(" Masukkan Jari-Jari : ");
jari_jari = s.nextInt();
luas_lingkaran = (jari_jari * jari_jari)*22/7;
System.out.print(" Luas Lingkaran = 22/7*("+jari_jari+"*"+jari_jari+") = " + luas_lingkaran);
System.out.println();
System.out.println("\nb. Luas Segitiga");
s = new Scanner(System.in);
System.out.print(" Masukkan Alas : ");
alas = s.nextInt();
System.out.print(" Masukkan Tinggi : ");
tinggi = s.nextInt();
luas_segitiga = (alas * tinggi)/2;
System.out.print(" Luas Segitiga = ("+alas+"*"+tinggi+")/2 = " + luas_segitiga);
System.out.println();
System.out.println("\nc. Luas Bola");
s = new Scanner(System.in);
System.out.print(" Masukkan Jari-Jari : ");
jari_jari = s.nextInt();
luas_bola = (jari_jari * jari_jari)*22/7*4;
System.out.print(" Luas Bola = 4*22/7*("+jari_jari+"*"+jari_jari+") = " + luas_bola);
System.out.println();
break ;
case 3 :
System.out.println("\nAnda Memilih Mencari Nilai Maksimum & Minimum");
Scanner dataMasukan = new Scanner(System.in);
Byte JmlData;
Byte DataArray[];
System.out.print("Jumlah data : ");
String BacaInput = dataMasukan.nextLine();
JmlData = new Byte (BacaInput);
DataArray = new Byte [JmlData];
for (int i = 0;i<JmlData;i++){
System.out.print("DataArray["+i+"] = ");
String BacaInput2 = dataMasukan.nextLine();
DataArray[i] = new Byte (BacaInput2);
}
System.out.println();
System.out.println("Menampilkan Data Yang Telah Dimasukkan");
for (int i = 0;i<JmlData;i++){
System.out.println("Hasil Data ["+i+"] = "+DataArray[i]);
}
int Maximum = DataArray[0];
for(int i=1;i<JmlData;i++){
if(Maximum < DataArray[i]){
Maximum=DataArray[i];
}
}
int Minimum=DataArray[0];
for(int i=1;i<JmlData;i++){
if(Minimum>DataArray[i]){
Minimum=DataArray[i];
}
}
System.out.println("\nNilai Maksimum\t: "+Maximum+" ");
System.out.println("Nilai Minimum\t: "+Minimum+" ");
break;
case 4 :
System.exit(0);
break;
default :
System.out.println("Data salah");
break;
}
}
}
Translate
Pengikut
Sukses Dinamo
https://www.facebook.com/yogi.senior?fref=ts
Cilok Ipul Putra Arsed
Java Battery
https://www.facebook.com/warsiyanto.warsiyanto.77?fref=ts
Entri Populer
-
Bissmillahirohmanirohim Tangerang, Mohon Do'a Restu untuk Rekan-rekan yang akan mengadakan penggalangan dana di sekitaran Serpong ...