Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Skills needed to complete this assignment:conditionals ,loops and functions.The keypad on your oven is used to enter the desired cooking time and is arranged

C++

Skills needed to complete this assignment:conditionals ,loops and functions.The keypad on your oven is used to enter the desired cooking time 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 time that cant be entered, then you would like to substitute a time that can be entered. Write a program that inputs a desired time . The cooking time must be between 00:01 and 09:59. If the desired time does not contain 1, 4, or 7, then output the desired time. Otherwise, compute the next longer time that does not contain 1, 4, or 7 and output

it. If the desired time is invalid (time is not between 00:01 and 09:59, or the minute argument is greater than 59), the program outputs error messages.

Example 1:

Input:

00:20

Expected output:

00:20

Explanation:

The desired time does not contain 1, 4, or 7.

Example2:

Input:

00:01

Expected output:

00:02

Example3:

Input:

00:47

Expected output:

00:50

template

include using namespace std;

// check whether a given time is between 00:01 and 09:59 bool isValid(int hours, int minutes); // check whether a given time contains digits 1, 4, or 7 bool containsDigits(int hours, int minutes); // print a given time in the format of hh:mm void printTime(int hours, int minutes);

int main() { int hours, minutes; char c; // to skip the ':' cout<<"Enter the desired time: "; cin >> hours >> c >> minutes; /* your code here */

return 0; }

bool isValid(int hours, int minutes){ /* your code here *

}

bool containsDigits(int hours, int minutes){ /* your code here */

}

void printTime(int hours, int minutes){

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions