Advertisement
Guest User

Untitled

a guest
May 27th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <cstdlib>
  4. #include <math.h>
  5. #include <ctime>
  6. using namespace std;
  7. int main(void)
  8. {
  9.     string choice;
  10.     string choice2;
  11.     float temp = 0.0;
  12.     float temp2 = -273.15;
  13.     bool looping = true;
  14.     while (looping == true)
  15.     {
  16.         cout << "Temperature Converter V1.1\n\n";
  17.         cout << "1.) Farenheit to Celsius Converter\n";
  18.         cout << "2.) Farenheit to Kelvin Converter\n";
  19.         cout << "3.) Celsius to Farenheit Converter\n";
  20.         cout << "4.) Celsius to Kelvin Converter\n";
  21.         cout << "0.) Exit\n";
  22.         cout << "> ";
  23.         cin >> choice;
  24.         system("clear");
  25.        
  26.         if (choice == "1") {
  27.             cout << "Temperature Converter V1.1:\n";
  28.             cout << "Farenheit to Celsius Converter\n\n";
  29.             cout << "What is the temperature in Farenheit: ";
  30.             cin >> temp;
  31.             temp = (temp - 32) * 5/9;
  32.             system("clear");
  33.             cout << "Temperature Converter V1.1:\n";
  34.             cout << "Farenheit to Celsius Converter\n\n";
  35.             cout << "The temperature is " << temp << " degrees Celsius." << "\n\n";
  36.             cout << "1.) Return to Main Menu\n";
  37.             cout << "2.) Exit Program\n";
  38.             cout << "> ";
  39.             cin >> choice;
  40.             while (looping == true)
  41.             {
  42.             if (choice == "1") // check that later
  43.             {
  44.                 system("clear");
  45.                 break;
  46.             }
  47.             if (choice == "2")
  48.             {
  49.                 cout << "\nExiting Program...";
  50.                 looping = false;
  51.             }
  52.             else
  53.             {
  54.                 system("clear");
  55.                 cout << "Unknown option: (" << choice << ")\n"
  56.                 << "Available Options: 1 & 2\n\nReverted back to Main Menu.\n"
  57.                 << "Bug is still being worked out. Thank you for your patience.\n\n";
  58.                 break;
  59.             }
  60.         }
  61.         }
  62.         else if (choice == "2")
  63.         {
  64.             cout << "Temperature Converter V1.1:\n";
  65.             cout << "Farenheit to Kelvin Converter\n\n";
  66.             cout << "What is the temperature in Farenheit: ";
  67.             cin >> temp;
  68.             temp = (temp - 32) * 5/9;
  69.             temp = temp + 273.15;
  70.             system("clear");
  71.             cout << "Temperature Converter V1.1:\n";
  72.             cout << "Farenheit to Kelvin Converter\n\n";
  73.             cout << "The temperature is " << temp << " degrees Kelvin." << "\n" << endl;
  74.             cout << "1.) Return to Main Menu\n";
  75.             cout << "2.) Exit Program\n";
  76.             cout << "> ";
  77.             cin >> choice;
  78.             while (looping == true)
  79.             {
  80.             if (choice == "1") // check that later
  81.             {
  82.                 system("clear");
  83.                 break;
  84.             }
  85.             if (choice == "2")
  86.             {
  87.                 cout << "\nExiting Program...";
  88.                 looping = false;
  89.             }
  90.             else
  91.             {
  92.                 system("clear");
  93.                 cout << "Unknown option: (" << choice << ")\n"
  94.                 << "Available Options: 1 & 2\n\nReverted back to Main Menu.\n"
  95.                 << "Bug is still being worked out. Thank you for your patience.\n\n";
  96.                 break;
  97.             }
  98.         }
  99.         }
  100.         else if (choice == "3")
  101.         {
  102.             cout << "Temperature Converter V1.1:\n";
  103.             cout << "Celsius to Farenheit Converter\n\n";
  104.             cout << "What is the temperature in Celsius: ";
  105.             cin >> temp;
  106.             temp = temp * 9/5 + 32;
  107.             system ("clear");
  108.             cout << "Temperature Converter V1.1:\n";
  109.             cout << "Celsius to Farenheit Converter\n\n";
  110.             cout << "The temperature is " << temp << " degrees Farenheit." << "\n" << endl;
  111.             cout << "1.) Return to Main Menu\n";
  112.             cout << "2.) Exit Program\n";
  113.             cout << "> ";
  114.             cin >> choice;
  115.             while (looping == true)
  116.             {
  117.             if (choice == "1") // check that later
  118.             {
  119.                 system("clear");
  120.                 break;
  121.             }
  122.             if (choice == "2")
  123.             {
  124.                 cout << "\nExiting Program...";
  125.                 looping = false;
  126.             }
  127.             else
  128.             {
  129.                 system("clear");
  130.                 cout << "Unknown option: (" << choice << ")\n"
  131.                 << "Available Options: 1 & 2\n\nReverted back to Main Menu.\n"
  132.                 << "Bug is still being worked out. Thank you for your patience.\n\n";
  133.                 break;
  134.             }
  135.         }
  136.         }
  137.         else if (choice == "4")
  138.         {
  139.             cout << "Temperature Converter V1.1:\n";
  140.             cout << "Celsius to Kelvin Converter\n\n";
  141.             cout << "What is the temperature in Celsius: ";
  142.             cin >> temp;
  143.             temp = temp + 273.15;
  144.             temp = round(temp);
  145.             system ("clear");
  146.             if (temp == temp2 )
  147.             {
  148.                 cout << "The temperature is 0 degrees Kelvin." << "\n" << endl;
  149.             }
  150.             else
  151.             {
  152.             cout << "Temperature Converter V1.1:\n";
  153.             cout << "Celsius to Kelvin Converter\n\n";
  154.             cout << "The temperature is " << temp << " degrees Kelvin." << "\n" << endl;
  155.             cout << "1.) Return to Main Menu\n";
  156.             cout << "2.) Exit Program\n";
  157.             cout << "> ";
  158.             cin >> choice;
  159.             while (looping == true)
  160.             {
  161.             if (choice == "1") // check that later
  162.             {
  163.                 system("clear");
  164.                 break;
  165.             }
  166.             if (choice == "2")
  167.             {
  168.                 cout << "\nExiting Program...";
  169.                 looping = false;
  170.             }
  171.             else
  172.             {
  173.                 system("clear");
  174.                 cout << "Unknown option: (" << choice << ")\n"
  175.                 << "Available Options: 1 & 2\n\nReverted back to Main Menu.\n"
  176.                 << "Bug is still being worked out. Thank you for your patience.\n\n";
  177.                 break;
  178.             }
  179.         }
  180.         }
  181.         }
  182.         else if (choice == "0")
  183.         {
  184.             cout << "Exiting Program...\n";
  185.             looping = false;
  186.         }
  187.         else
  188.         {
  189.             cout << "Unknown option: (" << choice << ")\n"
  190.             << "Available Options: 1, 2, 3, 4, 0.\n\n";
  191.         }
  192.     }
  193.     return 0;
  194. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement