I have this project where I create a program that calculates the area of a rectangular prism. I am suppose to print the results in printf this is what I have... is it correct? instructions ; Write a...


I have this project where I create a program that calculates the area of a rectangular prism. I am suppose to print the results in printf this is what I have... is it correct?



instructions ;


Write a Java program that computes the total surface area of a rectangular prism like the one below. There

are six sides, so the area of all sides has to be summed to get total area.


Inputs: The program should ask the user to enter the length (L), width (W), and height (H) for the object in

inches. So there are three inputs to the program.


Create a separate method from main to calculate the area.

Name the separate method calcArea and it needs to have three input arguments: length, width,

and height. The output of calcArea will return a double.

Outputs: The program should have this output (below is an example):

The total area for a rectangle prism inches long, inches wide, and inches tall is

square



inches.


Where A is the area your program calculates and must be formatted to two decimal places, e.g. 12.48,

using a printf statement.


Does it mean that they all have to be printf or just the results?




import
java.util.Scanner;



public
class
Chapter6ProjectFirstTry


{



public
static
void
main(String[] args)


{


Scanner input =
new
Scanner(System.in);


System.out.print("Enter the Length: ");



double
length =input.nextInt();


System.out.print("Enter the Width: ");



double
width = input.nextInt();


System.out.print("Enter the Height: ");



double
height = input.nextInt();



double
total = 2*(length * width)+2*(height*length)+2*(height*width);


System.out.print%f("The total Surface area for the rectangle prism is " +length+ " inches long, " +width+ " inches wide, and  " +height+ " inches tall " + total + " square inches. ");


}


}



Thank you








Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here