Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /***********************************
- Joseph Cognata
- 2/14/17
- This program will tell lowest and highest
- tempature needed for a oven with a broken
- pad that can not use 1, 4, 7.
- EX.
- Users temp: 430
- Lowest: 399
- Highest: 500
- ***********************************/
- int main(){
- int num1, num2, num3;
- char playAgain;
- do{
- cout << "The oven has broken and three digits don't work(1,4,7)." << endl;
- cout << "The user(you) will give an input of what tempature you need for cooking(Between 0-999)." << endl;
- cout << "This program will output a new number that is the best suited, if needed, to use." << endl;
- cout << "The tempature you will be cooking at(please press enter after each number): " << endl;
- cin >> num1 >> num2 >> num3;
- //validate they entered a number between 0 and 999
- while(num1 > 9 || num1 < 0 || num2 > 9 || num2 < 0 || num3 > 9 || num3 < 0){
- cout << "Error.... to try again please enter Y or N: " << endl;
- cin >> playAgain;
- if(playAgain == 'Y' || playAgain == 'y'){
- cout << "The oven has broken and three digits don't work(1,4,7)." << endl;
- cout << "The user(you) will give an input of what tempature you need for cooking(Between 0-999)." << endl;
- cout << "This program will output a new number that is the best suited, if needed, to use." << endl;
- cout << "The tempature you will be cooking at(please press enter after each number): " << endl;
- cin >> num1 >> num2 >> num3;
- }else{
- return 0;
- }
- }
- if ((num1 != 1 && num1 != 4 && num1 != 7) && (num2 != 1 && num2 != 4 && num2 != 7) && (num3 != 1 && num3 != 4 && num3 != 7)){
- cout << "The best tempature to use: " << num1 << num2 << num3 << endl;
- }else{
- if (num1 == 1 || num1 == 4 || num1 == 7){
- num1 - 1;
- num2 - 1;
- cout << "Lowest tempature to use: " << num1 - 1 << "99 \n";
- cout << "Highest tempature to use: " << num1 + 1 << "00\n";
- }
- else if (num2 == 1 || num2 == 4 || num2 == 7){
- cout << "Lowest tempature needed: " << num1 << num2 - 1 << "9\n";
- cout << "Highest tempature to use: " << num1 << num2 + 1 << "0\n";
- }
- else if (num3 == 1 || num3 == 4 || num3 == 7){
- cout << "Lowest tempature needed: " << num1 << num2 << num3 - 1 << endl;
- cout << "Highest tempature to use: "
- << num1 << num2 << num3 + 1 << endl;
- }
- else{
- cout << "Error.... to try again please enter Y or N: ";
- cin >> playAgain;
- }
- }
- cout << "To do again please enter Y or N: "; //<< endl;
- cin >> playAgain;
- }while(playAgain == 'Y' || playAgain == 'y');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement