I have created a C++ program but need assistance to \"This is the program and no
ID: 3692266 • Letter: I
Question
I have created a C++ program but need assistance to "This is the program and not sure how to get the"When the timer reaches zero, it beeps (by sending the alert character, ‘’ to the standard output device)" portion to work and how to get the timer to display "Each output should overwrite the previous value displayed like a real-world timer" The assignment and code are posted below. Need to design, implement and test a countdown timer class named Timer. This class mimics a real-world timer by counting off seconds, starting from the initial value. When the timer reaches zero, it beeps (by sending the alert character, ‘’ to the standard output device). Some appropriate operations might be the following: ---- Create a timer instantiating it to a specified number of seconds ---- Start the timer -----Reset the timer to some value When the Start operation is invoked, it should repeatedly decrement and output the current value of the timer approximately every second. To delay the program for one second use a For loop whose body does absolutely nothing : that is its body is the null statement. Experiment with the number of loop iterations to achieve as close to a one-second delay as you can. Display the timer value at the same position in the center of the screen. Each output should overwrite the previous value displayed like a real-world timer.
#include
#include
#include
#include
using namespace std;
int main() // start main
{
int h, m, s;
cout << "Countdown Timer Program " << endl;
cout << "Enter time in hours: " << endl;
cin >> h;
cout << "Enter time in minutes: " << endl;
cin >> m;
cout << "Enter time in seconds: " << endl;
cin >> s;
cout << "Press any key to start" << endl;
cout << "Countdown Timer Program" << endl;
cout << "time remaining" << endl;
cout << "hours : " << h << "mins : " << m << " secs : " << s << endl;
for (int hour = h; hour >= 0; hour--)
{
for (int min = m; min >= 0 ; min--)
{
if ( min == 0 && h > 0)
m = 59;
for (int sec = s; sec >= 0; sec--)
{
if ( sec == 0 )
s = 59;
Sleep(1000);
system("CLS");
cout << hour << " :hours " << min << " :mins " << sec << " :secs" << endl;
}
}
}
Sleep(1000);
cout << "Times Up!" << endl;
return 0;
}
Explanation / Answer
Ans;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.