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 <L> inches long, <W> inches wide, and <H> inches tall is <A> 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
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
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 ;
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
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images