| |
Due by 8:00 AM on Monday, September 20, 1998
This assignment consists of three problems that require you to work
with variables, user input, output, and simple arithmetic.
Notice that this assignment specifies required names for your program.
If the required name is Conversion1, then your code file should be
named Conversion1.java and the class name in your code should be
Conversion1. We will insist that you follow the specified names
because variable file names makes the graders' job very difficult.
- Write a program named Conversion1. Prompt the user to enter a
number of years and days. Tell the user how long that is in minutes
and how long that is in seconds. You should assume that years are
365.25 days long, but you should use
ints for all your
variables. Be careful how you account for that extra quarter day per
year. Here is a sample run:
How many years? 1
How many days? 3
That is 530280 minutes, or 31816800 seconds.
In a comment at the end of the program, explain, if you can, what causes the strange
change in results between 68 years 18 days and 68 years 19 days.
- Write a program named Conversion2 Prompt the user for a number of
seconds. Tell them how many days/hours/minutes/second it is. Here are
a few examples:
How many seconds? 3600
That is 0 days, 1 hours, 0 minutes, and 0 seconds.
How many seconds? 31816800
That is 368 days, 6 hours, 0 minutes, and 0 seconds.
How many seconds? 537462
That is 6 days, 5 hours, 17 minutes, and 42 seconds.
- Write a program named Dice which simulates a throw of a pair of
dice. That is, it generates and reports two random integers from 1 to
6 and their sum.
|