fork download
  1. //namespace convert_temperature (lab1-task2)
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. namespace CelsiusSpace
  6. {
  7. float ConvertToKelvin(float x)
  8. {
  9. return (x+273.15);
  10.  
  11. }
  12. }
  13. namespace FAhrenheitSpace
  14. {
  15. float ConvertToKelvin(float y)
  16. {
  17. return ((5/9.0*(y-32))+273.15);
  18. }
  19.  
  20. }
  21. int main()
  22. {
  23. float c,f;
  24. cout<<"Enter temperature in Celsius: ";
  25. cin>>c;
  26. cout<<"Enter temperature in Fahrenheit: ";
  27. cin>>f;
  28. cout<<"Temperature in Kelvin from Celsius input: "<<CelsiusSpace::ConvertToKelvin(c)<<endl;
  29. cout<<"Temperature in Kelvin from Fahrenheit input: "<<FAhrenheitSpace::ConvertToKelvin(f)<<endl;
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Enter temperature in Celsius: Enter temperature in Fahrenheit: Temperature in Kelvin from Celsius input: 2.57968e+38
Temperature in Kelvin from Fahrenheit input: 255.372