Задача # 9
Здравейте ! Някой може ли да ми помогне с решението на задачата.
import java.util.Scanner;
public class Tasc9 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String figureType = scanner.nextLine();
double area = 0;
switch (figureType){
case "square": {
double a = Double.parseDouble(scanner.nextLine());
area = a * a;
break;
}
case "rectangle":{
double a = Double.parseDouble(scanner.nextLine());
double b = Double.parseDouble(scanner.nextLine());
area = a * b;
break;
}
case "circle": {
double a = Double.parseDouble(scanner.nextLine());
area = (a * a) * Math.PI;
break;
}
case "triangle": {
double a = Double.parseDouble(scanner.nextLine());
double b = Double.parseDouble(scanner.nextLine());
area = a * b;
break;
}
}
}
}