Concept explainers
The keypad on your oven is used to enter the desired baking temperature and is arranged like the digits on a phone:
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
0 |
Unfortunately the circuitry is damaged and the digits in the leftmost column no longer function. In other words, the digits 1, 4, and 7 do not work. If a recipe calls for a temperature that can’t be entered, then you would like to substitute a temperature that can be entered. Write a program that inputs a desired temperature. The temperature must be between 0 and 999 degrees. If the desired temperature does not contain 1, 4, or 7, then output the desired temperature. Otherwise, compute the next largest and the next smallest temperature that does not contain 1, 4, or 7 and output both.
For example, if the desired temperature is 450, then the program should output 399 and 500. Similarly, if the desired temperature is 375, then the program should output 380 and 369.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Management Information Systems: Managing The Digital Firm (16th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- The Lottery Problem: • The lottery draws a number that is the winning number • The number should be between 0 and 999 • Have someone play • The person tells how many tickets they want • The person always does “quick pick” (let the computer pick the number for them) and gets one number between 0 and 999 for each ticket bought • The program reports how many tickets win of the ones bought • NOTE: A ticket “wins” if it matches the winning number previously chosen • Write working code with at least one function and one sub other than “main”arrow_forwardFlowcharts in Figure 2(a) with subroutine in Figure 2(b) are used to read 8 integer values by the user. If the number of positive numbers is greater than the number of negative numbers, the program will print "MORE POSITIVE" and vice versa. The program will also print "SAME" if the number of positive numbers equals with the number of negative numbers. The zero integer is a non-positive and non- negative number, its input is ignored. Input 8 integer numbers Output Message MORE POSITIVE, MORE NEGATIVE or SAME Start numPos = 0, numNeg=0 pos= 0, neg=0 [numpos, numNeg] = numPosNeg(pos, neg) numPos-numNeg False Print "MORE POSITIVE" numPos > numNeg False Print "MORE NEGATIVE" End Figure 2(a): Main flowchart with output True True Print "SAME" True True NumPosNeg (pos, neg) count=1 Read num num = 0 num > 0 False neg=neg +1 count = count + 1 count <= 8 False Return pos, neg Figure 2(b): Subroutine False True pos-pos + 1arrow_forwardwrite pseudocode that describes the process of guessing a number between 1 and 100. After each guess, the player is told that the guess is too high or too low. The process continues until the player guesses the correct number. Pick a number and have a fellow student try to guess it by following your instructions.arrow_forward
- Solve this please: A mobile phone app allows a user to press a button that starts a timer that counts seconds. When the user presses the button again, the timer stops. Draw a flowchart or write pseudocode that accepts the elapsed time in seconds and displays the value in minutes and seconds. For example, if the elapsed time was 130 seconds, the output would be 2 minutes and 10 seconds.arrow_forwardSlove by pythonarrow_forwardA county collects property taxes on the assessment value of property, which is 60 percent of the property’s actual value. If an acre of land is valued at $10,000, its assessment value is $6,000. The property tax is then 75¢ for each $100 of the assessment value. The tax for the acre assessed at $6,000 will be $45. Write a program that asks for the actual value of a piece of property and displays the assessment value and property tax.arrow_forward
- If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example, if the number that is input is 12391, then the output should be displayed as 23502.arrow_forwardBody mass index (BMI) is a measure of health based on weight. It can be calculated by taking your weight in kilograms and dividing it by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.arrow_forwardComputer sciencearrow_forward
- Collatz Sequence: In 1937, Lothar Collatz proposed that no matter what number you begin with, the sequence eventually reaches 1. This is widely believed to be true but has never been formally proved. Write a program that inputs a number from the user, and then displays the Collatz Sequence starting from that number. Stop when you reach 1. If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add 1 to get 3n + 1. Repeat the process indefinitely. Find out and print the maximum number that you can get in these calculations. ' Part-3: Please enter a number: 2051 6154 3077 9232 4616 2308 1154 577 1732 866 433 1300 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 The maximum number you get: 9232arrow_forwardUsing Python Write a program that displays all numbers from 1 to y that are divisible by x, where x and y are entered by the user:Example:if x = 3 and y = 30, the output is 3, 6, 9, 12, 15, 18, 21, 24, 27, 30arrow_forwardControl structures: In Java only please. Output the position of the largest number and the largest number in the squence a0, a1, a2....ak. For example, the largest number of the squence is 75, 226, 113, 340, 170, 85, 256, 128, 64, 32, 16, 8, 4, 2, 1 is 340, and it's position is 4. Test your program for the following values of x: 75, 111, 678, 732, 873, 2048, and 65535. Thank youarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,