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

Desperately seeking help PLEASE Area and Perimeter of Reactangle Computes the ar

ID: 3926436 • Letter: D

Question

Desperately seeking help PLEASE

Area and Perimeter of Reactangle

Computes the area and perimeter of a rectangle from the sides entered by the user. Then modify the program to also find the area and circumference of a circle from the radius entered by the user. And finally, find the area and perimeter of a triangle from the base and height entered by the user.

Enter the first side (as a decimal): 20.5
Enter the second side (as a decimal): 15.0
The area is 307.5
The perimeter is: 71.0

Enter the radius (decimal): 30.2
The area is:2,865.2557
The circumference is: 189.752

Enter the height of the triangle (decimal): 3.0
Enter the base of the triangle (decimal): 4.0
The area is: 6.0
The perimeter is 12.0

for the perimeter of a rectangle:
perimeter = 2 * (side1 + side2)

for the circumference of a circle:
circumference = 2 * PI * radius

for the perimeter of a triangle:
perimeter = base + height + hypotenuse

to find the hypotenuse of the right triangle:
hyptenuse2 = base2 + height2

Explanation / Answer

Application.java :-

import java.io.*;
class Application

{

public static void main(String[ ] args) throws IOException

{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

  
System.out.print(" Enter the first side:");

double side1 = Double.parseDouble(br.readLine()); // reading side1 from keyboard

System.out.print(" Enter the second side:");

double side2 = Double.parseDouble(br.readLine()); // reading side2 from keyboard

double area1 = side1*side2; // calculating area of the rectangle

System.out.println("The Area is:"+area1);

double perimeter1 = 2 * (side1 + side2); // calculating perimeter of the rectangle

System.out.println("The Perimeter is:"+perimeter1);

System.out.println();


System.out.print(" Enter radius:");

double radius = Double.parseDouble(br.readLine()); // reading radius from keyboard

double area2 = 3.14*radius*radius; // calculating area of the Circle

System.out.println("The Area is:"+area2);

double circumference = 2 * 3.14 * radius; // calculating circumference of the Circle

System.out.println("The circumference is:"+circumference);

System.out.println();


System.out.print("Enter the height of the triangle :");

double height = Double.parseDouble(br.readLine()); // reading height from keyboard

System.out.print("Enter the base of the triangle :");

double base = Double.parseDouble(br.readLine()); // reading base from keyboard

double area3 = (height*base)/2; // calculating area of the Triangle

System.out.println("The Area is:"+area3);

double hypotenuse = Math.pow(Math.pow(base,2)+Math.pow(height,2),0.5); // calculating hypotenuse of the // Triangle

double perimeter2 = height+base+hypotenuse; // calculating perimeter of the Triangle

System.out.println("The Perimeter is:"+perimeter2);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote