The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
JAVA CODE HELP PLEAAAASSSSSEEE lolÂ
My code attached, just need some help.Â
Â
 Modify your solution for to allow the user to choose the shape to compute and report. The change should make the "look and feel" of the program cleaner and the user experience less cumbersome. There are several selection structure implementations (if-else, switch) that can be used in the solution. The user should be provided with a "menu of choices" that will allow them to identify the shape they wish to work with. A typical session might look like this:
Choose the shape
1. Square
2. Rectangle
3. Circle
4. Triangle
5. Quit
Enter your choice: 1
Enter the side (as a decimal): 10.5
The area is 110.25
The perimeter is: 42.0
Â
Â
Â
MY CODE:Â
//********************************************************
// The program calculates the area of a rectangle
// based on values entered by the user.
//********************************************************
import java.util.Scanner;
public class Rectangle Area {
public static void main(String[] args) {
// TODO Auto-generated method stub
double side1 = 0.0;
double side2 = 0.0;
double radius = 0.0;
double base = 0.0;
double height = 0.0;
final double PI = 3.14159;
System.out.println("Enter the first side ");
Scanner inData; // A class that reads input
inData = new Scanner(System.in);
System.out.println("Enter the length of a side ");
side1 = inData.nextDouble();
System.out.println("Enter the length of second side ");
side2 = inData.nextDouble();
System.out.println("The area is " + side1 * side2);
System.out.println("The perimeter is " + 2 * (side1 + side2));
System.out.print("Enter the radius: ");
radius = inData.nextDouble();
double area11 = PI * radius * radius; //calculating area of circle
double peri1 = PI * radius * 2.0; //calculating perimeter of rectangle
System.out.println("The area is: " + area11);
System.out.println("The circumference is: " + peri1);
System.out.print("Enter the height of the triangle: ");
height = inData.nextDouble();
System.out.print("Enter the base of the triangle: ");
base = inData.nextDouble();
double area111 = (1.0 / 2.0) * base * height; //calculating area of triangle
double peri11 = Math.sqrt((height * height) + (base * base)) + height + base; //calculating perimeter of triangle
System.out.println("The area is: " + area111);
System.out.println("The perimeter is : " + peri11);
}
}
-----------