Computer Science, asked by ag2878924, 2 days ago

write a program to input using a function of area a circle b square C rectangle



please answer my question quickly






as your answer is correct so I I mark you as a brandlist ​

Answers

Answered by tanishkchahal90
1

Answer:

import java.util.Scanner;

public class KboatMenuArea

{

public void area() {

Scanner in = new Scanner(System.in);

System.out.println("Enter a to calculate area of circle");

System.out.println("Enter b to calculate area of square");

System.out.println("Enter c to calculate area of rectangle");

System.out.print("Enter your choice: ");

char choice = in.next().charAt(0);

switch(choice) {

case 'a':

System.out.print("Enter radius of circle: ");

double r = in.nextDouble();

double ca = (22 / 7.0) * r * r;

System.out.println("Area of circle = " + ca);

break;

case 'b':

System.out.print("Enter side of square: ");

double side = in.nextDouble();

double sa = side * side;

System.out.println("Area of square = " + sa);

break;

case 'c':

System.out.print("Enter length of rectangle: ");

double l = in.nextDouble();

System.out.print("Enter breadth of rectangle: ");

double b = in.nextDouble();

double ra = l * b;

System.out.println("Area of rectangle = " + ra);

break;

default:

System.out.println("Wrong choice!");

}

}

}

Similar questions