1. #include <iostream>
  2. #include <windows.h>
  3. using namespace std;
  4.  
  5. void main() {
  6. int option;
  7. bool flag = 0;
  8. float value, convert = 0;
  9. //Note to myself, system is not compatible with *nix I think
  10. system("title Temperature Convertions");
  11. system("Color C");
  12. cout << "Program that converts from Fahrenheit to Celsius or Celsius to Fahrenheit\n";
  13. do {
  14. cout << "Select one of this options: " << endl;
  15. cout << "Type 1 if you wish to convert from Celsius to Fahrenheit" << endl;
  16. cout << "Type 2 if you wish to Fahrenheit to Celsius" << endl;
  17. cout << "Type 3 if you wish to exit" << endl;
  18. cout << "What option would you take? : ";
  19. cin >> option;
  20. switch(option) {
  21. case 1:
  22. cout << "type the temperature in Celsius: ";
  23. cin >> value;
  24. cout << "The value in Fahrenheit would be: " << (convert = (value * 9)/5 +32) << endl;
  25. flag = 1;
  26. break;
  27. case 2:
  28. cout << "Type the temperature in Fahrenheit: ";
  29. cin >> value;
  30. cout << "The value in Celsius would be: " << (convert = (value - 32) * 5/9) << endl;
  31. flag = 1;
  32. break;
  33. case 3:
  34. cout << "See you next time\n";
  35. flag = 1;
  36. break;
  37. default:
  38. cout << "Incorrect option, please follow the instructions at the begining of the program";
  39. Sleep(1000);
  40. system("cls");
  41. break;
  42. }
  43. }while(flag == 0);
  44. system("pause");
  45. }