Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. double temp_wej, temp_wyj, x, y;
  6.  
  7. int main()
  8. {
  9.    
  10.     cout<<"Jaka temperature chcesz przeliczyc? 1 Celsjusz, 2 Fahrenheit, 3 Kelvin"<<endl;
  11.     cin>>temp_wej;
  12.     cout<<"Podaj wartość temperatury"<<endl;
  13.     cin>>x;
  14.     cout<<"Na jaką temperature przeliczasz ? 1 Celsjusz, 2 Fahrenheit, 3 Kelvin"<<endl;
  15.     cin>>temp_wyj;
  16.    
  17.        if( temp_wej == temp_wyj )
  18.            {
  19.              y = x;
  20.              cout<<"Temperatura po przeliczeniu wynosi "<<y<<endl;
  21.            }
  22.        else if ( temp_wej==1 and temp_wyj==2)
  23.             {
  24.                 y = ( x * 1.8 ) + 32;
  25.                 cout<<"Temperatura w Fahrenheitach wynosi "<<y<<endl;
  26.             }
  27.        else if ( temp_wej==1 and temp_wyj==3)
  28.             {
  29.                  y = x + 273.15;
  30.                  cout<<"Temperatura w Kelvinach wynosi "<<y<<endl;
  31.             }
  32.        else if ( temp_wej==2 and temp_wyj==1)
  33.             {
  34.                  y = ( x - 32 ) / 1.8;
  35.                  cout<<"Temperatura w Celsjuszach wynosi "<<y<<endl;
  36.             }
  37.        else if ( temp_wej==2 and temp_wyj==3)
  38.             {
  39.                  y = ( x + 459.67 )*5/9;                
  40.                  cout<<"Temperatura w Kelvinach wynosi "<<y<<endl;
  41.             }            
  42.        else if ( temp_wej==3 and temp_wyj==1)
  43.             {
  44.                  y = x - 273.15;
  45.                  cout<<"Temperatura w Celsjuszach wynosi "<<y<<endl;
  46.             }    
  47.        else if ( temp_wej==3 and temp_wyj==2)
  48.             {
  49.                  y = ( x * 1.8 ) - 459.67;
  50.                  cout<<"Temperatura w Fahrenheitach wynosi "<<y<<endl;
  51.             }
  52. system("PAUSE");
  53.  
  54. return EXIT_SUCCESS;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement