Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//
//INCLUDE files for :faren2celcius
//**************************************
//
iostream.h
fstream (not fstream.h)
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
Terms of Agreement:
By using this code, you agree to the following terms...
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
////////////////////////////////////////
////////////////
//
// This is a nice little proggy that wil
// l output
// farenheit to celsius, from 0-10001
//
// f2c.cpp by Timmothy C. Posey08/14/00
//
// v1.0
////////////////////////////////////////
////////////////
#include
#include
void main() {
float celsius; // floating, rather than int, so we can have decimals....
// Formula for F -> C is celsius * 0.
// 55 * (faren - 32)
cout << "Farenheit -> Celcius Converter by TPoise v1.0\n\n";
// prompting user for range
Range:
cout << "What's the range\? (Ex. 0 150)";
int low;
int high;
cin >> low >> high;
int diff = high - low;
if (diff >= 10001) // Just so we won't get bad users to try to buffer overflow the system
{
cout << "Enter a smaller range.\n";
goto Range;
}
std::fstream fout;
fout.open("f2c.txt" , std::ios::out);
if (!fout.is_open()) return;
// cout << "Making Table using ran
// ges of "; << low " through "; <
// < high '\n';
cout << "Farenheit to Celcius Conversion\n";
fout << "Farenheit to Celcius Conversion\n";
cout << "Farenheit\tCelcius\n";
fout << "Farenheit\tCelcius\n";
cout << "---------\t-------\n";
fout << "---------\t-------\n";
int faren2;
while (faren2 < high)
{
faren2 = low;
celsius = 0.55f * (faren2 - 32);
cout << faren2 << "\t\t" << celsius << '\n'; // print to screen
fout << faren2 << "\t\t" << celsius << '\n'; // print to file
low++;
}
//close the file
fout.close();
// end main
}