+ 2
Check my code's and improve it
coding for you to show talent
11 ответов
+ 4
Can you maybe send the url of your codes?
On PC it's very difficult (almost impossible) to find codes from a specific person...
+ 3
On PC you can't see the codes on the profile of the others.......
Just the XP, Badges, Courses and Certificates.
+ 3
/*Temperature conversion */
#include <iostream>
using namespace std;
int main()
{
int from , to;
float value;
string input_unit, output_unit= "";
string UnitString(int value);
cout<<"Temperature Conversion\n";
cout<<"\nEnter no of Unit to covert from : \n 1. Celsius\n 2. Farenheit\n 3. Kelvin\n";
cin>>from;
input_unit = UnitString(from);
cout<<"\nEnter no of Unit to covert to : \n 1. Celius\n 2. Farenheit\n 3. Kelvin\n";
cin>>to;
output_unit = UnitString(to);
cout<<"\nEnter The value to convert: ";
cin>>value;
cout << "You entered the value " << value << " in " << input_unit <<".\n";
/*converting given value from specified unit to Kelvin*/
switch(from) {
case 1:
value= value + 273.15; break;
case 2:
value= (value+459.67)*5/9; break;
case 3: break;
default: break;
}
/*converting value from Kelvin to specified unit*/
switch(to) {
case 1:
value= value-273.15; break;
case 2:
value= value*9/5-459.67; break;
case 3: break;
default: break;
}
cout<<"Converted Value is "<< value << " in " << output_unit << " .\n";
}
string UnitString(int value){
string unit= "";
switch(value) {
case 1:
unit = "Celsius";
break;
case 2:
unit = "Farenheit";
break;
case 3: unit= "Kelvin";
break;
default: unit = "Unit not valid.\n";
break;}
return unit;
}
As @Fronz-Tec said, it was really difficult to find your question via pc.
I made some little changes to you code and added a function, just to get a better output from the program. The logic you create seems to work as it should be (I tested it with a few input values).
Other changes that can be done may be some checks on input values.
I hope it can be useful in some way :)
(if there is a better way to share code make me know, since I can't find it..)
+ 2
go into my profile you can copy it directly just improve and paste in below the question
+ 2
ok I will trying to send url
+ 2
Glad you liked it :)
+ 2
if you have any other code for share..u can @silvia
+ 1
@Fronz-Tec if u have on fb can u send me your username...or email
+ 1
@silvia you done Great job
0
good job @silvia
0
@Yash Hi!
@___Yng___ Thank you
:)