By the end of this activity, a student should be able to:
- Understand the difference between a class and an object.
- Create objects from classes using BlueJ.
- Interact with objects using the public methods.
- Use parameters to pass information to methods.
- Set the state of an object.
- Create a static method.
Prompt the user to input their name using the following prompt exactly as shown below.
You're Jane's friend!
"What's your name?"
Jean Claude
NOTE: The input, such as "Jean Claude," should not appear in your output when executed in this Skill Builder. It is provided to simulate how your output would actually look if your program executed from the terminal or command line.
Prompt the user to input a floating-point number and assign it to a variable called spice
.
You're Jane's friend!
"What's your name?"
Jean Claude
Enter a floating-point number:
2.34
Calculate the mathematical expression and output the result so that the output looks like:
You're Jane's friend!
"What's your name?"
Jean Claude
Enter a floating-point number:
2.34
Well Jean Claude, the spice value resulted in 1.5047818732113996
You should use an assignment statement to store the value of the expression.
Please Note: The expression has the number 2 raised to the power of the value calculated from the expression .
convert the value of the expression,
for which you calculated previously to the nearest hundredth place so that the output looks as follows (NOTE: Do NOT use printf
to implement this part):
You're Jane's friend!
"What's your name?"
Jean Claude
Enter a floating-point number:
2.34
Well Jean Claude, the spice value resulted in 1.5047818732113996
And the converted value is 1.50
- Prompt the user to input a wall's height and width. Calculate and output the wall's area.
Enter wall height (feet):
12
Enter wall width (feet):
15
Wall area: 180 square feet
- Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet. Store this value using a const double variable. The output for the amount of paint needed should be displayed rounded to 2 digits after the decimal (i.e., use printf, see textbook for details on how to use printf).
Enter wall height (feet):
12
Enter wall width (feet):
15
Wall area: 180 square feet
Paint needed: 0.51 gallons
- Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to the nearest gallon. (2 pts)
Enter wall height (feet):
12
Enter wall width (feet):
15
Wall area: 180 square feet
Paint needed: 0.51 gallons
Cans needed: 1 can(s)