CS201 Assignment # 1 Complete and Tested Solution | Virtual Study Solutions

Adsetra Ads

 

 Hello Guys! this is complete and tested solution....but u must change variables names and as per assignment requirement it should be well commented ........so here is ur job to do comment where u think it is necessary

#include<iostream>

#include <cstdlib>

using namespace std;



int main()

{

         

   

double far_temp, kel_temp, cal_temp;



char opt, select;







     cout " ************* Temprature Conversion Calculator *************";



     cout "\n\n Please enter the temprature unit for which you want the conversion ";



     cout "\n 1. F for Fahrenheit to Celsius and Kelvin";



     cout "\n 2. C for Celsius to Fahrenheit and Kelvin";



     cout "\n 3. K for Kelvin to Fahrenheit and Celsius";



do // for do, while loop

{



     cout "\n\n Please enter you Option: ";



     cin >> opt;



  



     switch(opt) // switch statements



{        



     case 'f':



     case 'F':

          {         



            cout " Enter temprature in Farhenheit: ";



            cin >> far_temp;



            cal_temp = (far_temp  -  32)  *  5/9; 



            kel_temp = (far_temp + 459.67) * 5/9;

          

            cout " Celcius =" cal_temp;

           

            cout "\n Kelvin =" kel_temp;





            break;

}

         



     case 'c':



     case 'C':           

{

            cout " Please enter temprature in Celcius: ";



            cin >> cal_temp;



            kel_temp = cal_temp + 273.15 ;



            far_temp = cal_temp  *  9/5 + 32;

          

            cout " Farhenheit =" far_temp;



            cout "\n Kelvin =" kel_temp;







            break;

}

         



     case 'k':



     case 'K':

{        



            cout " Please enter temprature in Kelvin: ";



            cin >> kel_temp;



            cal_temp = kel_temp - 273.15 ;



            far_temp = (kel_temp - 273.14)  * 9/5 + 32;



            cout " Celcius =" cal_temp;



            cout "\n Farhenheit =" far_temp;

           break;        

}



          

     default:

{

            cout "\n Please enter valid option (C, F, K)";

}          

}

  

            cout"\n Do you want to continue (y/n):";

            cin>>select;



if(select=='n') //for exit



{

             system("pause");

}



}

while(select=='y'); //for loop
 

For important helping material related to the subject ( Solved MCQs, AssignmentsShort Notes, Solved Past Papers, E-Books, Recommended Books, FAQs, Help & Tutorials , Short Questions Answers & more). You must view all the featured discussion in this subject group.

Post a Comment

  1. can we do this witout do while loop

    ReplyDelete
  2. Dear All,

    Most of the solutions have not done following things:

    Repetition Structures (Loops)
    indented and well commented

    So do the above things in your assignments.

    ReplyDelete
    Replies
    1. Dear M tariq Malik

      repetition structure tu code main maujood hai ......

      indented ju mjhe behtr lga kr dia ziyada concept ni hai mujhe :P

      n comments ka main ne oooper e likh diya tha k who sb loog khud krein :P

      thnx k ap ne rply kia :)

      Delete

 

Top