Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please leave comments so i can see what you are doing. use #include <iostream> #

ID: 3543962 • Letter: P

Question

please leave comments so i can see what you are doing. use #include <iostream> #include <iomanip>

#include <cmath>

The pressure of a gas changes as the volume and temperature of the gas vary. Write a program that uses the Van Der Waals equation of state for a gas, (P + an2 / V2) (V - bn) = nRT to display, in tabular form, the relationship between the pressure and the volume of n moles of carbon dioxide at a constant absolute temperature(T). P is the pressure in atmospheres, and V is the volume in liters. The Van Der Waals constants for carbon dioxide are a = 3.593L2 middot atm/mol2 and b= 0.0427 L/mol. Use 0.08206 L middot atm/mol middot K for the gas constant R. Inputs to the program include n, the Kelvin temperature, the initial and final volumes in milliliter, and the volume increment between lines of the table. Your program will display a table that varies the volume of the gas from the initial to the final volume in steps prescribed by the volume increment. Here is a sample run: Please enter at the prompts the number of moles of carbon dioxide, the absolute temperature, the initial volume in milliliters, the final volume, and the increment volume between lines of the table. Quantity of carbon dioxide (moles) 02 Temperature (Kelvin) 300 Initial volume (milliliters) 400 Final volume (milliliters) 600 Volume increment (milliliters) 50 0.0200 moles of carbon dioxide at 300 Kelvin

Explanation / Answer

This code is approximated to 3 decimal points check this code
If you have any doubts comment here


#include<iostream>
using namespace std;
int main()
{
double n,t,in_v,fin_v,v_incre,i;
cout << "Quantity in moles =>";
//scanf("%lf",&n);
cin>>n;
cout << "Temperature in Kelvin=>";
cin>>t;
cout << "Initial volume in millilitres =>";
cin>>in_v;
cout << "Final volume in millilitres =>";
cin>>fin_v;
cout << "Volume increment in millilitres=>";
cin>>v_incre;
cout <<"Volume(ml) Pressure(atm) ";
for(i=in_v;i<=fin_v;)
{
cout <<i << " ";
double temp=0;
temp= n * 0.08206 * t;
temp=temp/((i/1000) - 0.0427 *n);
temp=temp + (((3.593 * n * n)*1000000)/(i*i));
cout << temp<<" ";
i+=v_incre;
}
return 0;
}