In this assignment you will be working with variables, and reading in user data with the Scanner
class.
Note, in the examples,
*
indicates user input.
Write a program called Calories.java
that computes the amount of calories a person burns in a week while walking. Each person burns a different amount of calories for every mile they walk. You will ask a user to input
The program will then print out how many calories the person burned that week by walking.
$ javac Calories.java; java Calories
How many miles did you walk each day? *2.3*
How many calories do you burn per mile? *100.2*
This week you burned 1613.22 calories by walking.
Requirements:
- Use
printf
Print out two decimal points
Write a program, Timer.java
that computes the time when the user will finish all of their tasks. The program should ask the user for the following information:
Here is an example
$ javac Tasks.java ; java Tasks
Enter the current hour: *23*
Enter the number of tasks: *1*
Enter the number of hours a task takes: *5*
You will finish at 4:00 o'clock.
$ javac Tasks.java ; java Tasks
Enter the current hour: *9*
Enter the number of tasks: *3*
Enter the number of hours a task takes: *2*
You will finish at 15:00 o'clock.
You can assume that all times are integers that represent the time on a [24-hr “military” clock. For example, 7 PM is 19:00, or 19, in this representation.
Requirements:
- Use
printf
, dont worry about minutes or seconds, just hours. Use the%
operator
Write a program, called Zoo.java
, which will ask a prompt the user for the following information:
and then prints out the following song:
$ javac Zoo.java; java Zoo
Please input an animal: *monkey*
Please input a noun: *honesty*
Please input an animal: *giraffes*
Please input a adjcetive: *insincere*
Please input a noun: *insincere*
Please input an animal: *elephant*
Please input an adjective: *dumb*
Please input an animal: *orangutans*
Please input an adjective: *skeptical*
Please input a drink: *rum*
The monkeys stand for honesty
giraffes are insincere
And the elephants are kindly but they're dumb
orangutans are skeptical
Of changes in their cages
And the zookeeper is very fond of rum
In a text file called README.txt
answer the following questions:
Dont forget: make sure to fill in the header in all of your java files.
Submit the following files to the assignment called HW01
on Gradescope:
Zoo.java
Timer.java
Calories.java
README.txt
Make sure to name these files exactly what we specify here. Otherwise, our autograders might not work and we might have to take points off.