fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void CF(float x)
  5. {
  6. x= ((x*180)/100)+32;
  7. cout<<"La temperatura in Fahreneit è "<<x<<endl;
  8. }
  9.  
  10. void FC (float x)
  11. {
  12. x= ((x-32)*100)/180;
  13. cout<<"la temperatura convertita in Celsius è "<<x<<endl;
  14. }
  15.  
  16. float x;
  17. char type;
  18.  
  19. int main() {
  20. cout<<"inserisci una temperatura e a che scala appartiene"<<endl;
  21. cin>>x>>type;
  22. cout<<"Temperatura= "<<x<<"\t"<<"Scala= "<<type<<endl;
  23.  
  24. if(type=='C') {CF (x);}
  25. else if (type=='F') {FC (x);}
  26. else {cout<<"Il tipo di scala indicato è errato"<<endl;}
  27.  
  28.  
  29.  
  30.  
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 5320KB
stdin
1
C
stdout
inserisci una temperatura e a che scala appartiene
Temperatura= 1	Scala= C
La temperatura in Fahreneit è 33.8