Portfolio Title





 

 

Student Portfolio >> Index >> Coding >> Exercise 2

#include <iostream.h>
         
int main ()
             {
             short int tempval;
 
// -----------------------------------
             // reads in temperature from the user
             // -----------------------------------
   do
   {
   cout << "Enter temperature value: \n";
   cin >> tempval;
   }
   while (tempval <= -40 || tempval > 50);
           
 
// -----------------------------------
             // checks input temperature and 
             // prints out appropriate message
             // -----------------------------------
   if (tempval < -5)
   {cout << "it was freezing \n";}
 //else if (tempval >= -5 && tempval <= 5)
   else if (tempval <= 5)
   {cout << "it was cold \n";}
 //else if (tempval >= 6 && tempval <= 20)
   else if (tempval <= 20)
   {cout << "it was warm \n";}
 else if (tempval > 20)
   {cout << "it was hot \n";}
           
 
//return 0;
}

 

<< Back                                                                                                                                                                                         Forward >> 

Coding | Website Scripting | Visual Design | Instructional Design | Website Design | Website Design Tools

 

Copyright 2005 Kerstin Kegel