All pastes #933120 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-08 03:04 UTC
rendered paste body
#include <iostream>
#include <fstream>   //for file input and output
#include <iomanip>
#include <math>

using namespace std;

int main (int argc, char *argv[])
{
	ifstream infile("surface.txt"); // associate surface.txt with infile
	
	int n;
	
	filein.open("surface.txt");  //opening file

	if (!filein.fail())
	{

		filein.ignore(80, '\n');
		filein>>length>>width>>height;

		cout<<" Length   Width   Height   Volume"<<endl;

		while(!filein.eof())
		{
			volume = length * width * height;
			cout<<setw(7)<<length<<setw(8)<<width<<setw(9)<<height<<setw(9)<<volume<<endl;
			filein>>length>>width>>height;
		}//end of while

	}//end of if

	else
	{
		cout<<"Error opening file"<<endl;
	} //end of else

	filein.close();

	return 0;
}