Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

http://pastie.org/8505642 Open the pastie to see the Question. I will offer you

ID: 3547147 • Letter: H

Question

http://pastie.org/8505642


Open the pastie to see the Question. I will offer you more points if you get me perfect answer. Please upload your answer with screenshot.


Geometry Calculator Write a program that displays the following menu: Geometry calculator Calculate the Area of a Circle Calculate the Area of a Rectangle Calculate the Area of a Triangle Quit Enter your choice (1 - 4). If the user enters 1, the program should, ask for the radius of the circle and then display its area. Use the following formula to calculate the circle's area: area pir 2 Use 3.14159 for pi and the radius of the circle for . If the user enters 2, the program should ask for the length and width of the rectangle, and then display the rectangle's area. Use the following formula to calculate the rectangle's area: area = length Times width If the user enters 3. the program should ask for the length of the triangle's base and its height, and then display its area. Use the following formula to calculate the area of the triangle: area = base Times height Times .5 If the user enters 4, the program should end.

Explanation / Answer


import java.util.Scanner;


public class calculator

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

System.out.println("Please select the menu: 1.Calculate the Area of the circle. "

+ "2.calculate the area of a rectange "

+ "3.calculate the area of a triangle "

+ "4.Quit");

int res=in.nextInt();

if(res==1)

{

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

double rad=in.nextDouble();

double area=3.14159*rad*rad;

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

}

else if(res==2)

{

System.out.println("Please enter the width and length of the rectangle");

double width=in.nextDouble();

double length=in.nextDouble();

double area=width*length;

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

}

else if(res==3)

{

System.out.println("Enter the height and base of the triangle ");

double height=in.nextDouble();

double base=in.nextDouble();

double area=height*base /2;

System.out.println("Area of the triangle="+area);

}

else

{

  

}

}

  

}