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 enter an “R”, then calculate using values read in for height and width. Use “Select/Case” statements for this lab. The formulas for each figure are: Circle : Area = 3.14 * radius * radius Square : Area = side * side Rectangle : Area = Height * Width
ANSWER: Here I am giving you the CODE and output if you have any problem then comment or like it please.
CODE:
import java.util.Scanner;
public class Area {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your choice C for Circle or S for square
or R for rectangle: ");
String Ch = sc.next() ;
if(Ch.equals("C")) {
System.out.println("Enter the radius of the circle:
");
float radius = sc.nextFloat();
float area = (float) (3.14 * radius * radius);
System.out.println("Area of the Circle will be :
"+area);
}else if(Ch.equals("R")) {
System.out.println("Enter the length and height of the
rectangle: ");
int Height=sc.nextInt();
int Width= sc.nextInt();
int Area = Height * Width;
System.out.println("Area of the rectangle:
"+Area);
}else if(Ch.equals("S")) {
System.out.println("Enter the side of the square:
");
int side=sc.nextInt();
int area= side*side;
System.out.println("Area of the square: "+area);
}else {
System.out.println("Wrong choice.");
}
}
}
OUTPUT:



Area Program – Build a Java Class to Calculate the area of a Figure(call it “Area.java”....
In Java Exercise #2: (Java) Design and implement a program (name it ComputeAreas) that defines four methods as follows: Method squareArea (double side) returns the area of a square. Method rectangleArea (double width, double length) returns the area of a rectangle. Method circleArea (double radius) returns the area of a circle. Method triangleArea (double base, double height) returns the area of a triangle. In the main method, test all methods with different input value read from the user. Document your...
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...
JAVA Code Requried Copy the file java included below. This program will compile, but, when you run it, it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create this. Below the main method, but in the Geometry class, create a static method called printMenu that has no parameter list and does not return a value. It will...
Please, modify the code below to use the Switch Statements in Java instead of “if” statements to make the decisions. import java.util.Scanner; public class Area { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter code(C for circle, R for rectangle, S for square): "); char code = in.next().charAt(0); if(code == 'C') { System.out.print("Enter radius: "); double radius = in.nextDouble(); System.out.println("Area of circle is " + (Math.PI * radius * radius)); } else if(code == 'R') {...
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.
Create a program that calculates the area of various shapes.
Console
Specifications
Create an abstract class named Shape. This
class should contain virtual member function named
get_area() that returns a double type.
Create a class named Circle that inherits the
Shape class and contains these constructors and member functions:
Circle(double radius)
double get_radius()
void set_radius(double radius)
double get_area()
Create a class named Square that inherits the
Shape class and contains these constructors and member functions:
Square(double width)
double get_width()
void...
Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....
Java Using NetBean Design a math method rectArea to calculate rectangle area = width * height. Your main program will get width and height from user and call rectArea for calculation and then the main program will show the final result.
Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...
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...