Username77177

Social/Temperature_calculator

May 10th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. // Coded by Username77177 with ♥ for Goal Gesture
  4. int main(int argc, char *argv[])
  5. {
  6.   cout << "1 - Fahrenheit to Celsius;\n2 - Celsius to Fahrenheit;\n3 - Celsius to Kelvin\n4 - Kelvin to Celsius\n: ";
  7.   float choice;
  8.   while (int(choice) != 1 && int(choice) != 2 && int(choice) != 3 && int(choice) != 4)
  9.   {
  10.     cin >> choice;
  11.   }
  12.   if (choice == 1) {
  13.     cout << "Введите температуру в Фаренгейтах:";
  14.     cin >> choice;
  15.     choice = (choice - 32) * 5 / 9;
  16.   }
  17.   else if (choice == 2)
  18.   {
  19.     cout << "Введите температуру в Цельсиях:";
  20.     cin >> choice;
  21.     choice = ((choice/5)*9) + 32;
  22.   }
  23.   else if (choice == 3)
  24.   {
  25.     cout << "Введите температуру в Цельсиях:";
  26.     cin >> choice;
  27.     choice += 273.15;
  28.   }
  29.   else {
  30.     cout << "Введите температуру в Кельвинах:";
  31.     cin >> choice;
  32.     choice -= 273.15;
  33.   }
  34.  
  35.   cout << "Полученная температура: " << choice << endl;
  36.   return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment