All pastes #354907 Raw Edit

Something

public text v1 · immutable
·published 2007-02-14 05:57 UTC
rendered paste body
/*

**************************
SKELETON SPEC SHEET 
Nick Buccinno 
2007
**************************

INPUT INFO					
prog2.txt

OUTPUT INFO	
convOut.txt

CONSTANTS
none

CONSTRAINTS		
none

OPERATIONS 
1. Open ofstream
2a. Reference input file
2b. If cannot be opened, display error
3a. Reference output file
3b. If it cannot be opened, display error
4. Determine conversion type using char input
5. Determine amount using int input 
6. Convert
7. Store to output file
8. Format and display on screen
9. Check for EOF
10. End

*/

#include <iostream>		// for cin, cout
#include <fstream>		// for ifstream and ofstream
#include <string>		// for string class
#include <conio.h>		// for getch()
#include <stdio.h>
#include <iomanip>

using namespace std;

int main()
{
	char convType,
		dummy;
	int temp;
	float convFar;
	float convCel;

	ifstream convIn;

	convIn.open("prog2.txt", ifstream::in);

	while (convIn.good())
	{
		ofstream convOut;

		convOut.open("output.txt", ofstream::out);

		while (convOut.good())
		{
			convType = convIn.get();
			if (convType == "F")
			{
				dummy = convIn.get(); 
				temp = convIn.get();
				(int)convCel = (temp * 9) / 5 + 32;
				convOut << temp;
				convOut << setprecision(2) << fixed << temp << " " << convCel << endl;
			}
			else if (convType == "C") 
			{
				dummy = convIn.get();
				temp = convIn.get();
				(int)convFar = (temp - 32) / 9  * 5;
				convOut << temp;
				convOut << setprecision(2) << fixed << temp << " " << convFar << endl;
			}
			else 
			{
				cout << "Error, wrong input type detected! ";
				getch();
			}
		}
	}
	getch();
	return 0;
}


------ Build started: Project: ProjectClass, Configuration: Debug Win32 ------
Compiling...
ProjectClass2.cpp
c:\documents and settings\sayo\my documents\visual studio 2005\projects\projectclass\projectclass\projectclass2.cpp(67) : error C2446: '==' : no conversion from 'const char *' to 'int'
        There is no context in which this conversion is possible
c:\documents and settings\sayo\my documents\visual studio 2005\projects\projectclass\projectclass\projectclass2.cpp(67) : error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
c:\documents and settings\sayo\my documents\visual studio 2005\projects\projectclass\projectclass\projectclass2.cpp(71) : error C2106: '=' : left operand must be l-value
c:\documents and settings\sayo\my documents\visual studio 2005\projects\projectclass\projectclass\projectclass2.cpp(75) : error C2446: '==' : no conversion from 'const char *' to 'int'
        There is no context in which this conversion is possible
c:\documents and settings\sayo\my documents\visual studio 2005\projects\projectclass\projectclass\projectclass2.cpp(75) : error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
c:\documents and settings\sayo\my documents\visual studio 2005\projects\projectclass\projectclass\projectclass2.cpp(79) : error C2106: '=' : left operand must be l-value
Build log was saved at "file://c:\Documents and Settings\Sayo\My Documents\Visual Studio 2005\Projects\ProjectClass\ProjectClass\Debug\BuildLog.htm"
ProjectClass - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========