Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


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

 

if u need assistance u can contact me:

Contact me here :P

 

 

 

 

 

#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

 

}                                        

Views: 1134

Attachments:

Replies to This Discussion

can we do this witout do while loop

yes u can ....with goto () function

 

hm ny goto funtion nai parha

+•÷ILLUSIONIST+•÷

plz join n add me on student ning as frnd.

/Cs201 assignment No. 1 complete solution according to requirement
#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

}

This code uses concept of function call. Following is the code and i am uploading the cpp file.

# include <iostream>
# include <cstdlib>
using namespace std;

float F, C, K;
char unit, start;

void selection()
{
cout "\n Please enter your option:"; cin >> unit;
switch (unit)
{
    case 'F':
    case 'f':
        cout "Enter temperature in Fahrenheit " ; cin >> F;
        C = (F - 32) * 5/9;
        K = (F + 459.67) * 5/9;  
        cout   "Celsius = " C endl;    
        cout   "Kelvin = " K endl;       
        break;
    case 'K':
    case 'k':
        cout "Enter temperature in Kelvin " ; cin >> K;
        C = K - 273.15;
        F = K    * 9/5 - 459.67;
        cout   "Celsius = " C endl;    
        cout   "Fahrenheit = " F endl;    
        break;
    case 'C':
    case 'c':
        cout "Enter temperature in Celsius " ; cin >> C;
        F = C * 9/5 + 32;
        K = C + 273.15;
        cout   "Fahrenheit = " F endl;    
        cout   "Kelvin = " K endl;    
        break;     
    default: cout "Enter a valid unit \n";
}
}

int main()
{

cout "*************Temperature Conversion Calculator*************" endl endl;
cout "Please enter the temperature unit for which you want the conversion" endl;
cout "1. F for Fahrenheit to Celsius and Kelvin \n";
cout "2. C for Celcius to Fahrenheit and Kelvin \n";
cout "3. K for Celsius and Fahrenheit \n";

selection();
do
{
    cout "Do you want to continue (y/n) " ; cin >> start;
    if (start =='y') {selection();}
}
while(start == 'y');

 system("pause");
}

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
float a,b,c;
char i,select;


cout"*************Temprature Conversion Caculator*************"endl;
cout"Please enter the temprature unit for which you want the conversion"endl;
cout"1. F for fahrenheit to celcius and kelvin"endl;
cout"2. C for celcius to farenheit and kelvin"endl;
cout"3. K for celcius and fahrenheit"endl;
coutendl;
do
{

cout"Please enter your option:"endl;
cin>>i;
switch(i)
{
case'C':
case'c':
{
cout"Enter the Temperature in Celsius:"endl;
cin>>a;
b=1.8*a+32.0;
c=a+273;
cout"Temperature in Fahrenheit is "bendl;
cout"Temperature in Kelvin is "cendl;

break;
}
case'F':
case'f':
{
cout"Enter the Temperature in Fahrenheit:";
cin>>b;
a=(b-32.0)/1.8;
c=(b+459.67)*5/9;
cout"Temperature in Celsius is "aendl;
cout"Temprature in Kelvin is"cendl;

break;
}
case 'k':
case 'K':
{
cout"Enter the temprature in kelvin:";
cin>>c;
b=c-459.67*9/5;
a=c-273.15;
cout"Temprature in Fahrenheit is"bendl;;
cout"Temprature in Celcius is"aendl;

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

}

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.

Dear juste 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 :) 

Good.

Here is my opinion. The solution you posted have few errors:

  • It does not accept Capital Y and N
  • Code is not indented
  • Few spells are wrong. First solution posted on ning got same spell mistakes.

Good Luck! 

=========

Dear, you don't need to make duplicate discussions for same assignment. There are already two discussions created. So kindly avoid it in the future.

Regards,

Juste

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

{              system("pause"); }

} while(select =='y'|| select == 'Y'); //for loop

}                                        

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service