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.


Do not copy this, try yourself. this is only for idea purpose. i added this in pdf and word format both.

Views: 3366

Attachments:

Replies to This Discussion

koi correct solution send kar do

Rubab .ccp ek file format jese hai k .doc Microsoft Word ki format ha.

.ccp file Dev C++ se open hoti and banti hai.

/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 All,

This is my suggestion only.

The Dev C++ version for x86/32 bit windows shared in LMS is beta version.

You can use the other version 5.4.2 It is stable and fast. If you need any help regarding this version he/she can contact me.

Regards,

J

RSS

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

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