Computer Science, asked by ajkyal2006, 5 months ago

Write a Java program for

Attachments:

Answers

Answered by ishikasin
0

Answer:

don't know dear..!!!

Explanation:

plss Mark me as a braniliest

Answered by anindyaadhikari13
1

Question:-

Write a menu driven program to perform the following tasks:-

i) Area of a circle.

ii) Area of a rectangle.

iii) Exit from the program.

Program:-

import java.util.*;

class Java

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("1. Area of a circle. ");

System.out.println("2. Area of a rectangle.");

System.out.println("3. Exit. ");

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

int c=sc.nextInt();

switch(c)

{

case 1:

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

double r=sc.nextDouble();

r=Math.PI*r*r;

System.out.println("Area is: "+r);

break;

case 2:

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

double l=sc.nextDouble();

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

double b=sc.nextDouble();

l*=b;

System.out.println("Area is: "+l);

break;

case 3:

System.exit(0);

break;

}

}

}

Similar questions