If you've looked at this web page
you'll see that I used to do a lot of SCUBA diving.
On shallow dives (up to about 90') I put normal air in my tanks.
For deeper dives I used
Nitrox (also known as
EANx).
Air has about 21% oxygen and 79% nitrogen,
while Nitrox varies from 21% oxygen and 79% nitrogen through to 40% oxygen and 60% nitrogen.
Using Nitrox allows you to stay down deeper for longer.
However, when using Nitrox you have to take care not to use a mixture that is too strong, i.e.,
with a too high percentage of oxygen.
This check is done using some simple mathematics:
- Find out how deep the dive will be, in feet.
- Decide on a mixture, i.e., the percentage of oxygen in the gas.
- Compute the ambient pressure for the dive.
To do this you need to know the "feet per atmosphere" constant, which for ocean diving is 33.
The ambient pressure is then the depth divided by the "feet per atmosphere" constant, plus 1.
- Compute the partial pressure of oxygen for the dive, equal to the fraction of oxygen
(percentage divided by 100) in the gas multiplied by the ambient pressure.
The recommended maximal partial pressure of oxygen is 1.4, and the contingency maximal
partial pressure of oxygen is 1.6.
If the computed partial pressure of oxygen for the dive exceeds these, I know the mixture is
too strong.
- Additionally, I compute an "oxygen pressure group" (for those who are divers, this is not
the same as the nitrogen pressure group).
The oxygen pressure group is an uppercase letter representing the partial pressure of oxygen
for the dive.
'A' represents a partial pressure of oxygen from 0.0 to less than 0.1,
'B' represents a partial pressure of oxygen from 0.1 to less than 0.2,
'C' represents a partial pressure of oxygen from 0.2 to less than 0.3,
etc.
If the oxygen pressure group is 'N' I know I'm close to the recommended maximal partial
pressure of oxygen, and if it's a letter after 'N' I know the mixture is too strong.
I'd like you to write me a computer program to do these calculations for me.
You'll have to get the depth and percentage oxygen in the gas as keyboard input - both will be
integers.
The output must provide the ambient pressure for the dive, the partial pressure of oxygen for the
dive, and the oxygen pressure group.
Additionally, it must output true/false status values indicating whether or not
the dive will exceed the recommended maximal and contingency maximal values for partial pressure
of oxygen.
Here what a sample run should look like (with the keyboard input shown in italics) ...
Enter depth and percentage O2 : 99 36
Ambient pressure : 4.0
O2 pressure : 1.44
O2 group : O
Exceeds maximal O2 pressure : true
Exceeds contingency O2 pressure : false
Luckily, someone has already done the analysis, resulting in the following structure chart ...
You must ...
- Do a design for the program, inspired by the structure chart. 0.5%
- Implement the program in Java.
Use methods according to the structure chart (do the input in the main method). 1.5%
- Try asking ChatGPT to do this labtask! It produces a nice design and a program that works.
However, neither reflect the structure chart as required, and the code does not comply
with my style requirements. Proceed as you wish!
Answer