CIS36A Homework 2 Summer 2022 Topic: Chapter 2 - Variables, Scanner class, arithmetic expressions Based on lecture 6/29/

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

CIS36A Homework 2 Summer 2022 Topic: Chapter 2 - Variables, Scanner class, arithmetic expressions Based on lecture 6/29/

Post by answerhappygod »

CIS36A Homework 2
Summer 2022
Topic: Chapter 2 - Variables, Scanner class, arithmeticexpressions
Based on lecture 6/29/22. DO NOT USE ANYTHING AFTER lecture6/29/22
Write a program to read user data and calculate thesurface area and volume of a cuboid.
Read the instructions for IntelliJ IDEA
If you are not using IntelliJ IDEA, you are on your own to dosimilar steps with other IDE software.
Create an IntelliJ project Homework2 and the Java classHomework2_XXXXX where XXXXX are the last 5 digits of your studentID.
Add the "import" statement of the Scanner class.
Add the program description before the "public class"statement
All the code you write for this homework must be between thebraces:
public static void main(String[] args)
{
// your code
}
Write the code to ask the user to enter 3 user input values forthe length, height and width of a cuboid, read the inputs, thencalculate the surface area and volume. Use the Java command lineinterface with Scanner class, not the graphical interface.
https://www.mathsisfun.com/geometry/cub ... risms.html
Write the code for these steps:
a- Add the code to display your full name and the purpose of thecode:
My name is xxxxxx xxxxxxxx
This program calculates the volume and surfacearea of a cuboid.
b- Add the code to define a variable of type 'double', with thename 'length'.
c- Write the code to prompt user to enter input length
Enter the cuboid length:
d- Write the code to read the user input into the lengthvariable
e- Add the code to define a variable of type 'double', with thename 'height'.
f- Write the code to prompt user to enter input height
Enter the cuboid height:
g- Write the code to read the user input into the heightvariable
h- Add the code to define a variable of type 'double', with thename 'width'.
i- Write the code to prompt user to enter input width
Enter the cuboid width:
j- Write the code to read the input into the width variable
k- Add the code to define a variable of type 'double', with thename 'cuboidVolume'.
Calculate the volume of the cuboid and set this variablevalue.
l- Add the code to define a variable of type 'double', with thename 'surfaceArea'.
Calculate the surface area of the cuboid and set this variablevalue.
This homework must use exactly 5 variables: length, height,width, cuboidVolume, surfaceArea
m- Display the volume output as follows:
Volume of the cuboid (length L,height H,widthW) is XXXXX
where L is the length variable value, W is the width variablevalue, H is the height variable value, and XXXXX is the volumevariable value. The values of L, H, W come from the appropriateinput variables, and are not hard-coded in the print displaystring.
For example:
Volume of the cuboid (length 10,height6.5,width 4.8) is XXXX
n- Display the surface area output as follows:
Surface area of the cuboid (lengthL,height H,width W) isYYYY
where L is the length variable value, W is the width variablevalue, H is the height variable value, and A is the surfaceAreavariable value. The values of L, W, H and YYYY come from theappropriate variables, and are not hard-coded in the print displaystring.
For example:
Surface area of the cuboid (length 10,height6.5,width 4.8) is YYYY
Do a project build in to compile your code. Make sure there isno error.
Run your code and verify all results in the outputconsole.
The output should look similar to this, except that it shouldyour name, not "Tony Nguyen":
My name is Tony Nguyen.
This program calculates the volume and surface area of acuboid.
Enter the cuboid length: 15.5
Enter the cuboid height: 7.6
Enter the cuboid width: 8.3
Volume of the cuboid (length 15.5, width 7.6, height 8.3) is977.74
Surface area of the cuboid (length 15.5, width 7.6, height 8.3)is 619.06
--------------------
Sample output 1 by IntelliJ IDEA
—----------------------------
Sample output 2 by IntelliJ IDEA
You should run your code with different input values and verifythe results
Submit only the Java file Homework2_XXXX,java.
How do I upload a file as an assignment submission inCanvas?
You can submit multiple times, but all submission must occurbefore the due time.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply