public class lingkaran{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double phi = 3.14;
double r, luas,keliling;
System.out.println("Program Luas Lingkaran\n");
System.out.print("Masukkan Panjang Jari-jari : ");
r = input.nextDouble();l
uas = 0.5 * phi * r * r;
keliling = 2 * phi * r;
System.out.print("Luas Lingkaran = " + (int)luas + " \nKeliling lingkaran = "
+ (int)keliling);
}
}
import java.io.*;
class kuis
{
public static void main(String args[]) throws IOException
{
System.out.println("----------------------------------");
System.out.println("Pilihan Menu : ");
System.out.println("1. Menghitung Volume Balok");
System.out.println("2. Keluar");
System.out.println("----------------------------------");
//Membuat turunan class untuk Input dari User
BufferedReader kata = new BufferedReader
(new InputStreamReader(System.in));
System.out.print("Pilihan ? [1-3] : ");
int pilihan = Integer.parseInt(kata.readLine());
//punggunaan case
switch(pilihan)
{
case 1:
System.out.println("Anda memilih Menghitung Balok !");
System.out.print("Panjang :");
double p = Double.parseDouble(kata.readLine());
System.out.print("Lebar :");
double l = Double.parseDouble(kata.readLine());
System.out.print("Tinggi :");
double t = Double.parseDouble(kata.readLine());
double v = p*l*t;
System.out.println("Hasilnya Adalah :" + v);
break;
case 2:
System.out.println("Keluar !");
break;
default:
System.out.println("Batas input antara 1-2 !");
break;
}
//akhir case
}
}
0Awesome Comments!