vinochick 0 Newbie Poster

I need to write a program that uses P = (nRT)/V
P = pressure
V = volume
n = number of moles
R= universal gas constant (8.31 j/mol K)
T = absolute temperatre

All variables must be local, no global variables. Inputs to the program include kelving temp, initial and ffinal volumes in cubic meters, and volume increment between lines of the table. It will display a table that varies the volume of the gas from the initial to the final volume in steps indicated by the volume increment. The inputs must be obtained using a void function with imputs passed to function by reference. Pressure calculation should be in value returning function where the value of the pressure is returned and stored in an array that can hold up to 20 values. I will need a loop to display the data.

"Please enter at the prompts the number of moles of carbon dioxide, the asolute temperature, the initial volume in milliliters, the final volume, and the increment volume between lines of the table."

Quantity of Carbon Dioxide (moles) =
Temperature (Kelvin)=
Initial Volume =
Final Volume =
Volume increment =


Here is the IPO chart I have so far. What would I need to include in my void function and how do I write the array and loop?

Input
Number of moles of CO2
Absolute temperature
Initial volume in milliliters
Final volume
Increment volume between lines of the table
Universal gas constant
Pressure


Processing
None

Output
Volume
Pressure

Algorithm
1. Enter Quantity of CO2
2. Enter Temperature(Kelvin)
3. Enter Initial Volume
4. Enter Final Volume
5. Enter Volume increment
6. Pressure = the number of moles multiplied by universal gas constant multiplied by absolute temperature all divided by volume
7. Final Volume = initial volume + volume increment
Double n = 0.0;
Int T = 0;
Double vIn = 0.0;
Double vFin = 0.0;
Doulbe vIncr = 0.0;
Const r = 8.31;
Double P = 0.0;

Cout << “Volume, m3”;
Cout << “Pressure, N/m2”;


Cout << “Quantity of Carbon Dioxide = “;
Cout << “Temperature (Kelvin) =”;
Cout << “Initial Volume (m3) =”;
Cout << “Final Volume (m3) =”;
Cout << “Volume increment (m3) =”;

P = (n*r*T)/vFin

vFin = vIn + vIncr