1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#include <iostream>
using namespace std;
int main ()
{
int t1, d1, d2, t2, d3, d4, t3, d5, d6;
//each t(#) is the digit input and each d(#) is +-1 from t
char yes;
//char used to repeat loop
cout<<"You have a oven that has number pads from 0-9 but the numbers 1, 3, \n";
cout<<"and 7 are broken.\n";
cout<<"This program will calculate the lowest and highest temperature the\n";
cout<<"oven can produce when a broken number is entered.\n"<<endl;
//start of loop
do
{
cout<<"Enter the desired temperature (with spaces between the digits):\n";
cin>>t1>>t2>>t3;//1st digit, 2nd digit, 3rd digit
if (t1==1)//loop for whenever the first digit is 1
{
d1=0;//1-0 and 1+1
d2=2;
cout<<d1;
if ((t2==1)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<d1<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<d2;
//loop when 1st and 2nd digit is 1 and the 3rd digit is not a broken number
if ((t2==4)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<3<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<5;
if ((t2==7)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<6<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<8;
if (((t2==0)||(t2==2)||(t2==3)||(t2==5)||(t2==6)||(t2==8)||(t2==9)||(t3==0))&&((t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<t2<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2;
//loop when 1st digit is 1 and 2nd and 3rd digit is not a broken number
}
else if (t1==4)
{
d1=3;//4-1 and 4+1
d2=5;
cout<<d1;
if (((t2==0)||(t2==2)||(t2==3)||(t2==5)||(t2==6)||(t2==8)||(t2==9))&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<t2<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2;
//loop when 1st digit is 4 and 2nd and 3rd digit is not a broken number
if ((t2==1)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<0<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<2;
if ((t2==7)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<3<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<4;
if ((t2==4)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<d1<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<d2;
//loop when 1st and 2nd digit is 4 and the 3rd digit is not a broken number
}
else if (t1==7)//loop for whenever the first digit is 7
{
d1=6;//7-1 and 7+1
d2=8;
cout<<d1;
if ((t2==7)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<d1<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<d2;
//loop when 1st and 2nd digit is 7 and the 3rd digit is not a broken number
if ((t2==1)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<0<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<2;
if ((t2==4)&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<3<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2<<4;
if (((t2==0)||(t2==2)||(t2==3)||(t2==5)||(t2==6)||(t2==8)||(t2==9))&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<t2<<t3<<" is the lowest temperature you can enter and your highest is: "<<d2;
//loop when 1st digit is 7 and 2nd and 3rd digit is not a broken number
}
if ((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))
cout<<t1;
//the output of the 1st digit will be the user input when it is not a broken number
//the same method used for t1 is used in t2 and t3
if (t2==1)
{
d3=0;
d4=2;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&& ((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<d3<<t3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==4))
cout<<d3<<t3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<t3;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==7))
cout<<d3<<t3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<t3;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==1))
cout<<d3<<d3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<d6;
}
else if (t2==4)
{
d3=3;
d4=5;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<d3<<t3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==7))
cout<<d3<<6<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<8;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==1))
cout<<d3<<0<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<2;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==4))
cout<<d3<<d3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<d4;
}
else if (t2==7)
{
d3=6;
d4=8;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&((t3==0)||(t3==2)||(t3==3)||(t3==5)||(t3==6)||(t3==8)||(t3==9)))
cout<<d3<<t3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4;
if (((t1==0)||(t1==2)||(t1==3)||(t1==5)||(t1==6)||(t1==8)||(t1==9))&&(t3==4))
cout<<d3<<3<<" is the lowest temperature you can enter and your highest is: "<<t1<<d4<<5;
|