Created
December 15, 2023 14:11
-
-
Save rafirh/e709e91296ad3cc9003774e08c0ee247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
String kelas = scanner.nextLine(); | |
String nama = scanner.nextLine(); | |
System.out.println("Nama : " + nama); | |
System.out.println("Kelas : " + kelas); | |
System.out.println(); | |
int pilihanBangunDatar = Integer.parseInt(scanner.nextLine()); | |
if (pilihanBangunDatar == 1) { | |
int panjang = Integer.parseInt(scanner.nextLine()); | |
System.out.println("Persegi"); | |
int luas = panjang * panjang; | |
System.out.println(luas); | |
} else if (pilihanBangunDatar == 2) { | |
int alas = Integer.parseInt(scanner.nextLine()); | |
int tinggi = Integer.parseInt(scanner.nextLine()); | |
System.out.println("Segitiga"); | |
int luas = alas * tinggi / 2; | |
System.out.println(luas); | |
} else if (pilihanBangunDatar == 3) { | |
int jariJari = Integer.parseInt(scanner.nextLine()); | |
System.out.println("Lingkaran"); | |
double luas = jariJari * jariJari * 22 / 7; | |
System.out.println(luas); | |
} else { | |
System.out.println("Input Anda tidak sesuai"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment