V22.0002 - ASSIGNMENT 2

An integral part of scuba safety is the management of the nitrogen levels in your body.  If you have too much nitrogen in your body, you can get the bends.  Todays scuba divers use charts and computers to determine how long they can be submerged at a particular depth.

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:

  • The desired depth of the next dive
  • The number of previous dives during the day

    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
    21 - 30 feet 75 minutes minus 80% of the depth exceeding 20 feet
    31 - 40 feet 68 minutes minus 100% of the depth exceeding 30 feet
    41 - 50 feet 58 minutes minus 120% of the depth exceeding 40 feet
    51 - 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
    0 0 minutes
    1 4 minutes
    2 10 minutes
    3 17 minutes
    4 27 minutes

    It should then output the following:

  • Maximum Depth
  • Bottom time without the Secondary Dive Penalty
  • Secondary Dive Penalty
  • Maximum Bottom Time

    Example:
    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 (ie. Use JOptionPane to get a string and then use Integer.parseInt() to convert that string to an integer).  When you output the times, you can either:

  • Output your times as float values as shown above (ie. three and one half minutes would look like this 3.50)
  • break the fractional portion of your minutes into its equivalent in seconds. (ie. three and one half minutes would look like this 3:30)

    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.