Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class AreaOfFigures_07 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String figure = scanner.nextLine();
- double a = Double.parseDouble(scanner.nextLine());
- double square = a * a;
- double circle = a * a* Math.PI;
- if (figure.equals("square")) {
- System.out.printf("%.3f", square);
- } if (figure.equals("rectangle")) {
- double b = Double.parseDouble(scanner.nextLine());
- double rectangle = a * b;
- System.out.printf("%.3f", rectangle);
- }
- if (figure.equals("circle")) {
- System.out.printf("%.3f", circle);
- } if (figure.equals("triangle")) {
- double b = Double.parseDouble(scanner.nextLine());
- double triangle = a * b / 2;
- System.out.printf("%.3f", triangle);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement