I'm trying to convert Celsius temps to Fahrenheit and output them to the screen. The temps need to come from a file and it needs to loop until it hits -999(sentinel value)
I've been messing around with this all afternoon and I can't seem to get it to work, which is odd because it was assignment 3 out of 6 for homework, so it should have been easy. Here is what I have-
I've been messing around with this all afternoon and I can't seem to get it to work, which is odd because it was assignment 3 out of 6 for homework, so it should have been easy. Here is what I have-
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
double sentinel = -999;
double f=0;
double c=0;
ifstream fin;
fin.open("temps.txt");
if (!fin.good()) throw "I/O error";
while (true)
{
fin >> c;
fin.ignore(1000, 10);
if (c = -999) break;
f = (9.0 / 5) * c + 32;
cout << "The temperature in degrees F is " << f << endl;
} // while
return 0;
} // main
Last edited: