Computer Science, asked by happiness18, 15 days ago

please solve itㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ​

Attachments:

Answers

Answered by Anonymous
2

Answer:

import java.util.Scanner;

class MenuDriven

{

  public static void main(String[] args)

  {

          //Declaration

         Scanner input = new Scanner(System.in);

         double radius, height, volume, area;

         int side1, side2, sum, choice;

     

         //Initialization

        radius = 0.0;

        height = 0.0;

        sum = 0;

        sides = 0;

        //Display the menu to the user

       System.out.println("1. Calculate the volume of a sphere");

       System.out.println("2. Print the Message - A B C");

       System.out.println("3. Calculate the area of a trapezium");

       

       //Prompt and accept the choice of the user

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

       choice = input.nextInt();

 

       //Display accordingly

      switch(choice)

      {

          case 1:

          System.out.println("Enter the radius of the sphere : ");

          radius = input.nextDouble();

          volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);

         System.out.println("The volume of the sphere whose radius is = " + volume);

           break;

           

           case 2:

          System.out.println(" A B C");

          break;

   

          case 1:

          System.out.println("Enter the value of the first parallel side of the trapezium : ");

          side1 = input.nextInt();

           System.out.println("Enter the value of the second parallel side of the trapezium : ");

          side2 = input.nextInt();

          area = (1.0/2.0) * height * (side1 + side2);

          System.out.println("The area of the trapezium is = " + area);

           break;      

          default:

          System.out.println("Invalid input.");

       }

   }

}

Similar questions