Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your program should prompt the user to type in an integer value as the desired o

ID: 3653678 • Letter: Y

Question

Your program should prompt the user to type in an integer value as the desired oven temperature. You may assume that this temperature is between 0 and 999. If the number does not contain 1,4, or 7 then output the given number. Otherwise compute the smallest number that is not smaller than n that does not contain a 1,4, or 7. Compute the largest number that is not greater than n that does not contain 1,4, or 7 and prints out both of these numbers. define the following functions: bool containsDigit(int number, int digit); // returns true if number contains digit, otherwise returns false int ceilValid(int number); // returns the smallest valid integer that is no smaller than number. For example, containsDigit(123,4) is false because digit 4 is not in 123; containsDigit(400,0) is true because digit 0 is in 400. bool valid(int number);// returns false if number contains 1, 4 or 7; otherwise returns true You should use function calls to containsDigit() in the definition/implementation of the function valid. A function is valid if it doesnt contain a 1,4, or 7. What is the oven temperature you want to set to? 350 Go ahead key in 350. 350 What is the oven temperature you want to set to? 375 The temperature is not valid, try to key in 380 or 369 #include using namespace std; int main () using notepad ++ compiler is visual studio command prompt please help

Explanation / Answer

#include using namespace std; bool containsDigit(int number, int digit){ int num=number, temp; for(int i=100;i>0;i/=10){ num=number/i; temp=num%i; if(temp==digit) return true; } return false; } bool valid(int number){// returns false if number contains 1, 4 or 7; otherwise returns true if( containsDigit(number, 1)==true) return false; if( containsDigit(number, 4)==true) return false; if( containsDigit(number, 7)==true) return false; return true; } int ceilValid(int number){ // returns the smallest valid integer that is no smaller than number. while(valid(number)==false){ number++; } return number; } int floorValid(int number){ // returns the largest valid integer that is no larger than number. while(valid(number)==false){ number--; } return number; } int main(){ int oventemp; for(int i=0;i