Write a program in Java that can calculate and output the area of three different shapes; a rectangle, a triangle and a circle. Let the user choose which shape they want by typing the words “rectangle”, “triangle” or “circle” (you may use integers, strings or chars to indicate which shape the user prefers to calculate the area of). Then, have the user enter the values of the dimension(s) appropriate for each shape in the form of doubles.
Test.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args)throws
IOException {
//for taking console input
BufferedReader br = new
BufferedReader(new InputStreamReader (System.in));
String shape;
double area, l, h, b, r;
System.out.print("Enter the shape:
");
shape = br.readLine();//getting
shape
shape = shape.toLowerCase();
switch(shape) {//using swwitch case
for determining correct shape
case "triangle":
System.out.println("Enter Dimensions");
System.out.print("Base: ");
b =
Double.parseDouble(br.readLine());
System.out.print("Height: ");
h =
Double.parseDouble(br.readLine());
area =
(h*b)/2.0;//triangle area formula
System.out.printf("Area of the Triangle is %.2f",area);
break;
case "rectangle":
System.out.println("Enter Dimensions");
System.out.print("Length: ");
l =
Double.parseDouble(br.readLine());
System.out.print("Breadth: ");
b =
Double.parseDouble(br.readLine());
area =
l*b;//rectangle area formula
System.out.printf("Area of the Rectangle is %.2f",area);
break;
case "circle":
System.out.println("Enter Dimensions");
System.out.print("Radius: ");
r =
Double.parseDouble(br.readLine());
area =
3.14*r*r;//circle area formula
System.out.printf("Area of the Circle is %.2f",area);
break;
default:
System.out.println("Wrong Choice! Try Again");
break;
}
}
}
Program Screenshot

Output

Write a program in Java that can calculate and output the area of three different shapes;...
Write a Java program that prompts user to select one of the five shapes(Rectangle, Square, Triangle, Circle, and Parallelogram), then calculate area of the shape,must have input validation and uses more of java library like math class, wrapper class, string methods, use formatted output with the printf method. Finally, create a pseudo-code statement and flowchart
Write a Java program that prompts user to calculate area of five different shapes using java library, and at least 2 classes - more of OOP, also use divide and conquer methods.
Using C++, Write a program that will provide the user a menu from which the user may select to calculate the area of one of four geometric shapes: a circle, a rectangle, a triangle, and a trapezoid. You should use the most appropriate SWITCH block for this program. The user will input all data needed to calculate the area. The program should output all data input by the user, the calculated area, and the geometric shape selected. Run this program...
Java only please Write a program that displays the following menu: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Triangle 3. Calculate the Area of a Rectangle 4. 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 formula: area = ∏r2 Use 3.14159 for ∏. If the user enters 2 the program should ask for...
Area Program – Build a Java Class to Calculate the area of a Figure(call it “Area.java”. The figure may be a circle, or a square or a rectangle. The user will enter the type of figure they want through a Scanner. If they enter a “C”, proceed to calculate the area of the Circle using values read in for radius. If they enter an “S”, then calculate the area of a Square using values read in for side. If they...
#1 Write a java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle. Depending on that input - the program must call either the Triangle method or the Rectangle method. Each of those methods must receive 2 input fields from the user - one for base and one for height in order...
Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape from the information supplied. Write pseudocode to solve this problem and write a Python program that asks the user to input the required information for a shape and then calculates the area of the shape. Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1...
GUI bouncing shapes program
use this interface
the out put of the program should be a jFrame with three
buttons: “add triangle”, “add square” and “add circle” and a blank
screen. when the user clicks any of these buttons the corresponding
shape appears and starts bouncing around the screen. the shape of
these shaoes and randomized and anytime the user clicks the button
you should be able to keeping adding shapes on the screen while the
previosus shape is bouncing...
part A) using java methods calculate the area of rectangle. part B) modify to calculate the area of rectangle, circle, triangle and square this time using switch statement, input validation, loop for choices and document the program.
java language
Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...