I need help with my program. The program reads water temperatures and when they were recorded from an input file called " biodata2.txt." Then the output is displayed in a file called "results.txt" So the input file looks like this:
2 // number of readings taken
200707211245 // date recorded
F70.5 // Fahrenheit temperature
200708220812// date recorded
C19.97// Celsius temperature
So, the program rearranges the data to look like this:
Number of Recordings found: 2
C19.97-- recorded on 08/21/2007 at 08:12, etc. for any other data records.
I am also supposed to convert all Fahrenheit readings to Celsius. This is were the problem is, I read in the temperature in Fahrenheit using "inFile >> temp" and input it into the formula with result being "celsius" variable. The out put I get is -0 instead of the correct answer. Can anyone help me?
Passiongamer25 0 Light Poster
Recommended Answers
Jump to PostMaybe post your formula for converting F to C?
You didn't do 5/9 by any chance, which would be 0
As opposed to say 5.0/9.0 which is nearer to what you want.
Jump to PostHeh - 9/5, how about that then ^^^^^
Jump to PostYou'd have to post your latest code, and highlight the line containing the error message.
Jump to Post> float celcius = (temp-32)/ 1.8 << endl;
So what's the endl doing at the end of this calculation?
Jump to PostWell you did input temp as a string (this time), and not as a float (like last time).
Focus on what's being said, and stop making a bunch of random changes each time.
All 19 Replies
Salem 5,265 Posting Sage
MosaicFuneral 812 Nearly a Posting Virtuoso
Passiongamer25 0 Light Poster
Salem 5,265 Posting Sage
StuXYZ 731 Practically a Master Poster
Passiongamer25 0 Light Poster
MosaicFuneral 812 Nearly a Posting Virtuoso
Passiongamer25 0 Light Poster
Salem 5,265 Posting Sage
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Passiongamer25 0 Light Poster
Salem 5,265 Posting Sage
Passiongamer25 0 Light Poster
Salem 5,265 Posting Sage
Passiongamer25 0 Light Poster
hsoni007 0 Newbie Poster
Salem 5,265 Posting Sage
hsoni007 0 Newbie Poster
Passiongamer25 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.