/* Celsius Fahrenheit Table - This program is an updated version of ProgrammingChallenge 3.12. This version uses a loop to display a table of the Celsiustemperatures 0-20, and their Fahrenheit equivalents. */#include "Utility.h"int main(){/* Constants: Minimum temperature in Celsius,Maximum temperature in Celsius */const int CELSIUS_MIN = 0,CELSIUS_MAX = 20;/* Variables: Temperature in Celsius (counter variable, declared andinitialized to CELSIUS_MIN), Temperature in Fahrenheit */double degreesCelsius = CELSIUS_MIN,degreesFahrenheit = 0;/* Display: General Information, Formatted table header */cout << "\t\tCelsius to Fahrenheit Converter\n\n"<< "This program converts temperatures in Celsius (0 to 20)\n"<< "and displays their Fahrenheit equivalent.\n";cout << "\nTemperature Celsius" << "\t\t\t\t" << "Temperature Fahrenheit\n"<< "_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\n";/* For loop: As long as the temperature in Celsius is lower than orequal to 20, this loop will iterate */for (degreesCelsius; degreesCelsius <= CELSIUS_MAX; degreesCelsius++){/* Calculation: Conversion from Celsius to Fahrenheit */degreesFahrenheit = (degreesCelsius * 9 / 5) + 32;/* Display: Output */cout << "Deg. C.\t" << degreesCelsius << "\t\t\t\t\t"<< "Deg. F.\t" << degreesFahrenheit << endl;}pauseSystem();return 0;}
Friday, December 16, 2016
Programming Challenge 5.12 - Celsius Fahrenheit Table
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment