C++ while statement Convert Celsius to Fahrenheit for a range of value

Description

C++ while statement Convert Celsius to Fahrenheit for a range of value

#include <iostream>
#include <iomanip>
using namespace std;
int main()//from   ww w  .java2 s. c om
{
   const int MAX_CELSIUS = 50;
   const int START_VAL = 5;
   const int STEP_SIZE = 5;
   int celsius;
   double fahren;
   cout << "DEGREES   DEGREES\n" << "CELSIUS  FAHRENHEIT\n" << "-------  ----------\n";
   celsius = START_VAL;
   // Set output formats for floating-point numbers only
   cout << setiosflags(ios::showpoint) << setprecision(2);
   while (celsius <= MAX_CELSIUS)
   {
      fahren = (9.0/5.0) * celsius + 32.0;
      cout << setw(4)  << celsius << fixed << setw(13) << fahren << endl;
      celsius = celsius + STEP_SIZE;
   }
   return 0;
}



PreviousNext

Related