Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package prak401;
- import java.util.Scanner;
- public class prak401 {
- public static void main(String[] args) {
- Scanner masukan = new Scanner(System.in);
- int pilihan=9;
- do{
- System.out.println("\nMENU\n");
- System.out.println("1. menghitung luas persegi");
- System.out.println("2. Menghitung Luas Lingkaran");
- System.out.println("0. Keluar");
- System.out.println("Masukkan Pilihan Anda :");
- pilihan = masukan.nextInt();
- switch(pilihan){
- case 1 : luasPersegiPanjang();break;
- case 2 : luasLingkaran();break;
- }
- }
- while(pilihan !=0);
- }
- /* irfan */
- private static void luasPersegiPanjang() {
- Scanner masukan = new Scanner(System.in);
- float panjang, lebar, luas;
- System.out.println("Masukan nilai panjang : ");
- panjang = masukan.nextInt();
- System.out.println("Masukan nilai lebar : ");
- lebar = masukan.nextFloat();
- luas = panjang * lebar ;
- System.out.println("Luas persegi panjang : " + luas);
- }
- private static void luasLingkaran() {
- Scanner masukan = new Scanner(System.in);
- float jari2, luas;
- System.out.println("Masukkan nilai jari jari : ");
- jari2 = masukan.nextFloat();
- luas = 3.14f * jari2 * jari2;
- System.out.println("Luas lingkaran :" + luas);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement