I have created a program, but I can not get it to match the sample run provided. Any suggestions? I really just need someone to look over, it could be something simple.
Here is what sample inputs are just going down list
//Setup standard environment
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void title ()
{
// Output program name
cout << endl;
cout<< " Assignment 4 " <<endl;
}
int main ()
{
//Variable declarations
const double constant_a= 3.592, constant_b= 0.0427, constant_r=0.08206;
double v, n, t, initialv, finalv, increment, pressure; //Defined all used variable
char sentinel; //sentinel=n continue
//sentinel=y done
// Display title
title ();
cout <<endl <<endl;
cout << "Please enter at the prompts the number of moles of carbon \ndioxide, the absolute temperature, the initial volume in \nmilliliters, the final volume, and the increment volume \nbetween lines of the table. \n\n";
cout << "Please enter quantity of carbon dioxide (moles): ";
cin >> n;
cout << "\nPlease enter the temperature (kelvin): ";
cin >> t;
cout << "\nPlease enter initial volume (milliliters): ";
cin >> initialv;
cout << "\nPlease enter the final volume (mililiters): ";
cin >> finalv;
cout << "\nPlease enter the volume increment (mililiters): ";
cin >> increment;
cout << endl << n <<" moles of carbon dioxide at " << t <<" kelvin. \n \n";
cout << " Volume (ml) Presure (atm)\n\n";
for (v = initialv; v <= finalv; v +=increment)
{
(pressure= ((n*constant_r*t)/(v-(constant_b*n)))-((constant_a*n*n)/(v*v)));
Yea I wrote a c++ all in one chemistry calculator my junior year...I'll see if I still have the source, and see if I can figure out something that will help. It's probably in the equation you used. I can't think of anywhere else your code would fall through.
yay! that made so much sense. That's fixed. So one last question, how can I cut it off from adding e-.05706 or whatever. I just want it to stop after 6 places, i.e. 1.2246