For this assignment, you are to write a program to compute the maximum bottom time for a sport diver based on a few variables. NOTE: This is an oversimplified example for this class and will not compute safe bottom times.
Your program should ask the user for:
Then it must calculate the maximum time permitted at the desired depth. For this assignment, we will assume a sport diver does not dive below 60 feet. Furthermore, we assume a diver will not participate in more than 5 dives in one day.
Following is a table you can use to calculate the bottom time without regard to the number of previous dives:
|Desired Depth||Maximum Bottom Time (without Secondary Dive Penalty)|
|1 – 20 feet||90 minutes minus 75% of the maximum depth|
|20 – 30 feet||75 minutes minus 80% of the depth exceeding 20 feet|
|30 – 40 feet||68 minutes minus 100% of the depth exceeding 30 feet|
|40 – 50 feet||58 minutes minus 120% of the depth exceeding 40 feet|
|50 – 60 feet||44 minutes minus 150% of the depth exceeding 50 feet|
The Secondary Dive Penalty is an amount deducted from your maximum bottom time due to the nitrogen contained in your blood from previous dives:
|Number of previous dives||Penalty|
It should then output the following:
Enter the maximum depth of your next dive in feet: 44
Enter the number of dives you have completed already today: 2
|44||Feet Maximum Depth|
|53.20||Bottom time without the Secondary Dive Penalty|
|10.00||Secondary Dive Penalty|
|43.20||Maximum Bottom Time|
You should read integer values from the user. When you output the times, you can either:
In either case, alignment of the output values is important.
You must use if / else if / else statements to choose
between the formulae for calculating the Bottom Time without the Secondary Dive
Penalty. (Even if you can figure out the single formula to calculate the bottom
time for any depth.)
You should use a switch statement to determine the Secondary Dive Penalty.