Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String type = scanner.nextLine();
- float laturaPatrat=Float.parseFloat(scanner.nextLine());
- float razaCerc = Float.parseFloat(scanner.nextLine());
- float latimeDreptunghi = Float.parseFloat(scanner.nextLine());
- float lungimeDreptunghi = Float.parseFloat(scanner.nextLine());
- int ok=0;
- if(type.equals("square")) {
- System.out.printf("%.2f",laturaPatrat * laturaPatrat);
- ok=1;
- }
- else{
- if(type.equals("rectangle")) {
- System.out.printf("%.2f",latimeDreptunghi * lungimeDreptunghi);
- ok=1;
- }
- }
- if(type.equals("circle")) {
- System.out.printf("%.2f",Math.PI * razaCerc * razaCerc);
- ok = 1;
- }
- if(ok==0)
- System.out.println("Unknown figure");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment