Program to convert temperature from celsius to fahrenheit


Question 1) You would create a program that would do temperature conversions, from Celsius to Fahrenheit, and from Fahrenheit to Celsius. Your program will read input from a text file named “temps.txt”. This file would contain the following information:

• A letter, ‘c’ or ‘f’, which indicates type of the temperature given

• The temperature itself your main function will read data from the file. Your program would have 2 functions:

i) One function to validate the data. Temperatures can’t be below absolute zero. Look up the temperatures for Celsius and Fahrenheit representations for absolute zero. If temperature given is below this threshold, then you must return a flag back to main() which indicates this.

ii) Other function to do all conversions. This function should be of type void, and would be called temp_convert. If the letter read from the file is ‘c’, then you must convert to Fahrenheit. If the letter read is ‘f’, then you must convert to Celsius. There should be NO return statements in this function.

Continue to read data from the file until you run out of data: don’t count how many lines of data there are and make your reading dependent on that. Consider: if different-length input file was run against your code, will your project break? Your project must be able to run input files of all lengths. Output the results in the well-formatted table. You would have a column of Celsius temperatures, and a column of Fahrenheit temperatures. If any temperature was below the absolute zero threshold, then the table must say “Too Cold!” where the conversion would have otherwise been. (Use your “flag” from above to execute this.) Make use of formatting methods we have discussed this semester to make your columns straight and even.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Program to convert temperature from celsius to fahrenheit
Reference No:- TGS04645

Expected delivery within 24 Hours