CISS-110 Project 2
This project deals with reading input from the user, storing the input into variables, and displaying those variables. This program is an introductory project into the primitive data types int
, double
, and the String
class.
Learning outcomes
- Build a program from the ground up.
- Using correct data types.
- Watching for lost precision in calculations.
- Interaction with Java Compiler.
- Reviewing reported errors and deducing needed repairs.
- Successful compilation of the project.
- Confirmation program produces desired results.
The following identifiers will be used:
int diameter, height;
double radius;
double circumference, areaOfCircle, cylVolume;
String name;
You will utilize the Scanner
class plus the print()
and println()
methods of System.out
. You will also define a double
named constant whose value is 3.1415926 to be used for PI.
Math
class has a constant value called PI
, do not use the Math.PI
constant in this program.Prompt the user for their name and, using the nextLine()
method, read the name of the user. Once the name of the user has been read, greet the user. Proceed to get the diameter and height of some aluminum can (cylinder) using the nextInt()
method.
Calculate the circumference of the base of the can, the area of the base (using the pow()
method of the Math
class), and the volume of the cylinder. Display the radius, diameter, circumference, area of the base, and volume of the cylinder.
Remember that the radius is half of the diameter. Circumference = PI * diameter Area of circle = PI * radius ^ 2 Volume of cylinder = Area of circle * height
Your output should resemble (user-provided values in bold italic):
Enter your name: Bill Hello, Bill. You have two more answers to provide. Enter the integer diameter of a cylinder: 5 Enter the integer height of the cylinder: 8 The radius is 2.5. The diameter is 5. The height is 8. The circumference is 15.707963. The area of the base is 19.63495375. The volume of the cylinder is 157.07963.
Submit the project to the Learning Management System as Project2_lastname.java.