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

The pressure of a gas changes as the volume and temperature of the gas vary. We

ID: 3758022 • Letter: T

Question

The pressure of a gas changes as the volume and temperature of the gas vary. We are all familiar with the ideal gas equation of state which relates pressure, specific volume and temperature (Pv RT) where P is the pressure, v is the specific volume, R is the gas constant and T is the absolute temperature. There are many other equations of state used to describe the relationship between P, v and T. Another common one is the Van der Waals equation of state given as:ospheres V = Volume (L) T = Temperature (K) R = Gas Constant = 0.08206 (L atm) / (mol K) for Carbon Dioxide a = 3.592 L^2atm / mol2 for Carbon Dioxide b = 0.0427 L / mol for Carbon Dioxide n = number of mole (mol) Write a program that will use the Van der Waals equation of state to display in tabular form the relationship between pressure, volume and temperature for carbon dioxide, inputs to the program include n, the temperature in K, and the initial and final volumes in milliliters 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 final volume in steps prescribed by the volume increment. A sample run should look like this: Please enter at the prompts the number of moles of carbon dioxide, the absolute temperature, the initial volume in milliliters, the final volume in milliliters, and the increment volume between lines in the table. Quantity of carbon dioxide (moles) > 0.02 Temperature (K) > 300 Initial Volume (milliliters) > 400 Final Volume (milliliters) > 600 Volume increment (milliliters) > 50 0.02 moles of carbon dioxide at 300 Kelvin

Explanation / Answer

#include <iostream>
#include <string.h>

using namespace std;

float Cel(float cels)
{
      return (cels + 273.15); //Celsius to Kelvin
}

float Far(float far)
{
      float cel = (far-32)/(9/5);
      float kel = Cel(cel); //Farenheit to Kelvin
      return kel;
}

float leftsolve(float a, float b, float c, float R)
{
      return ( (a*b*R)/c );
}

float rightsolve(float a, float b, float c, float R)
{
      return( (b*c)/(R*a) );
      }

int main(int argc, char* argv[])
{
    float temp, pressure, volume, moles, R;
    float Rp[3] = {.08205746, 62.36367, 8.314472};
    int control;
    control = 0;
    if(argc != 4)
    {
          
            return 1;
    }
    else
    {
        if(control == 0)
        {
            if (strcmp(argv[3],"/atm"))
            {
            R = Rp[0];
            }
            else
              if(strcmp(argv[3],"/torr"))
              {
              R = Rp[1];
              }
            else
            if(strcmp(argv[3],"/kPa"))
            {
            R = Rp[2];
            }
            control++;
        }
        else if(control == 1)
        {
             if(!strcmp(argv[1],"/t"))
             {
             cout<<"Enter temperature: ";
             cin>>temp;
             if(argv[2] == "/f")
             {
             temp = Far(temp);
             }
             else
               if(argv[2] == "/c")
               {
               temp = Cel(temp);
               }
             }
             control++;
        }
        else if(control == 2)
        {
                 if(strcmp(argv[1],"/p"))
                 {
                   cout<<" Enter Volume: ";
                   cin>>volume;
                   cout<<" Enter number of moles: ";
                   cin>>moles;
                   cout<<" Pressure equals: " << leftsolve(temp, moles, volume, R);
                 }
                 else if(strcmp(argv[1],"/v"))
                 {
                 cout<<" Enter Pressure: ";
                 cin>>pressure;
                 cout<<" Enter number of moles: ";
                 cin>>moles;
                 cout<<" Volume equals: "<< leftsolve(temp, moles, pressure, R);
                 }
                 else if(strcmp(argv[1],"/n"))
                 {
                 cout<<" Enter Pressure: ";
                 cin>>pressure;
                 cout<<" Enter Volume: ";
                 cin>>volume;
                 cout<<" Number of moles equals: "<< rightsolve(pressure, volume, temp, R);
                 }
                 else if(strcmp(argv[1],"/t"))
                 {
                 cout<<" Enter Volume: ";
                 cin>>volume;
                 cout<<" Enter Pressure: ";
                 cin>>pressure;
                 cout<<" Enter number of moles: ";
                 cin>>moles;
                 cout<<" Temperature equals: " << rightsolve(pressure, volume, moles, R);
                 }
        }
    }
    return 0;
}

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote