Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. /***********************************
  4. Joseph Cognata
  5. 2/14/17
  6. This program will tell lowest and highest
  7. tempature needed for a oven with a broken
  8. pad that can not use 1, 4, 7.
  9. EX.
  10. Users temp: 430
  11. Lowest: 399
  12. Highest: 500
  13. ***********************************/
  14. int main(){
  15. int num1, num2, num3;
  16. char playAgain;
  17.  
  18. do{
  19. cout << "The oven has broken and three digits don't work(1,4,7)." << endl;
  20. cout << "The user(you) will give an input of what tempature you need for cooking(Between 0-999)." << endl;
  21. cout << "This program will output a new number that is the best suited, if needed, to use." << endl;
  22. cout << "The tempature you will be cooking at(please press enter after each number): " << endl;
  23. cin >> num1 >> num2 >> num3;
  24.  
  25. //validate they entered a number between 0 and 999
  26. while(num1 > 9 || num1 < 0 || num2 > 9 || num2 < 0 || num3 > 9 || num3 < 0){
  27. cout << "Error.... to try again please enter Y or N: " << endl;
  28. cin >> playAgain;
  29. if(playAgain == 'Y' || playAgain == 'y'){
  30. cout << "The oven has broken and three digits don't work(1,4,7)." << endl;
  31. cout << "The user(you) will give an input of what tempature you need for cooking(Between 0-999)." << endl;
  32. cout << "This program will output a new number that is the best suited, if needed, to use." << endl;
  33. cout << "The tempature you will be cooking at(please press enter after each number): " << endl;
  34. cin >> num1 >> num2 >> num3;
  35. }else{
  36. return 0;
  37. }
  38. }
  39.  
  40. if ((num1 != 1 && num1 != 4 && num1 != 7) && (num2 != 1 && num2 != 4 && num2 != 7) && (num3 != 1 && num3 != 4 && num3 != 7)){
  41. cout << "The best tempature to use: " << num1 << num2 << num3 << endl;
  42. }else{
  43. if (num1 == 1 || num1 == 4 || num1 == 7){
  44. num1 - 1;
  45. num2 - 1;
  46. cout << "Lowest tempature to use: " << num1 - 1 << "99 \n";
  47. cout << "Highest tempature to use: " << num1 + 1 << "00\n";
  48. }
  49. else if (num2 == 1 || num2 == 4 || num2 == 7){
  50. cout << "Lowest tempature needed: " << num1 << num2 - 1 << "9\n";
  51. cout << "Highest tempature to use: " << num1 << num2 + 1 << "0\n";
  52. }
  53. else if (num3 == 1 || num3 == 4 || num3 == 7){
  54. cout << "Lowest tempature needed: " << num1 << num2 << num3 - 1 << endl;
  55. cout << "Highest tempature to use: "
  56. << num1 << num2 << num3 + 1 << endl;
  57. }
  58. else{
  59. cout << "Error.... to try again please enter Y or N: ";
  60. cin >> playAgain;
  61. }
  62. }
  63.  
  64. cout << "To do again please enter Y or N: "; //<< endl;
  65. cin >> playAgain;
  66.  
  67. }while(playAgain == 'Y' || playAgain == 'y');
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement