Unit #3 Homework Problem (Solution)
Course Outline HW & Programming Assignements
Sol3hw4b

#include <iostream.h>

#include <math.h>

main()

{

float vol1=0.0, vol2=0.0, work=1.0, kTemp=0.0;

const float R = 8.31451;

int n = 1; // number of moles

int k;

while( work != 0.0)

{

cout <<"\n\n Enter the work in joules ( 0.0 to stop) ";

cin >> work;

if(work == 0.0) break;

cout <<" \n Enter the initial volume in liters ";

cin >> vol1;

cout <<" \n Enter the temperature in degrees Kelvin ";

cin >> kTemp;

vol2 = vol1 * exp( work / ( n*R*kTemp));

cout << " \n\n The final volume is " << vol2 << " liters ";

}

cout <<"\n\n END OF PROGRAM";

char hold;

cout<<" \n\n Enter e (Exit) to terminate ";

cin >> hold;

}

A TYPICAL RUN:

Enter the work in joules ( 0.0 to stop) 670

Enter the initial volume in liters 3.5

Enter the temperature in degrees Kelvin 281

 
The final volume is 4.66241 liters

 
Enter the work in joules ( 0.0 to stop) 0

 
END OF PROGRAM

Enter e (Exit) to terminate