Question
I am making a military time program in Pelles C and I need some help to meet these requirements. (I posted this question multiple times
I am making a military time program in Pelles C and I need some help to meet these requirements. (I posted this question multiple times already and the solutions were wrong each time or incomplete so I will try to make the instructions more specific to what I need)
Learning how to Output data all over the Console Window. Requirements: 1. Create a C program. 2. Display the clock on row 3, col 20. The clock format will be as follows: [ 0 : 00: 00 ] 3. Loop thru all of the seconds in the day, from 0:0:0 to 23:59:59. 4. Have the user hit any key to start the clock. 5. The clock will sleep after displaying each second. The initial sleep time will be 100ms. 6. By hitting keys, the user will be able to change the sleep time anywhere between min: 100ms to max: 2000ms. 7. In real time, detect, these keystrokes: a. + : This will increase the sleep time by 100ms. Do not go over the maximum limit. b. - : This will decrease the sleep time by 100ms. Do not go below the minimum limit. c.
Programming Tips 1. You MUST use nested WHILE loops.
IMPORTANT FOR SOLUTION:
- Do not include any other libraries besides the ones mentioned below, because Pelles C will not recognize certain file types (So please keep the solution code as simple as possible for these requirements).
- No break or exit statements.
#include
- My current code does not run, and I need help with fixing the errors (and maybe cleaning it up, I would really appreciate it):
#incorporate
int principal() { int hour = 0, minute = 0, second = 0, sleep_time = 100;
printf("Press any key to begin the clock "); getchar();//Trust that client will press a key
while (hour < 24) { while (minute < 59) { while (second < 59) { system("cls");//Clear the control center printf("\033[3;20H[%02d:%02d:%02d]", hour, minute, second);//Show the clock at line 3, col 20 singe key = getchar(); in the event that (key == '+') {//Increment rest time sleep_time += 100; sleep_time = sleep_time > 2000 ? 2000 : sleep_time; } else if (key == '- ') {//Reduction rest time sleep_time - = 100; sleep_time = sleep_time < 100 ? 100 : sleep_time; } else if (key == 27) {//Handle get away from key printf("\033[100;1H");//Move cursor to lower part of control center bring 0 back; } else if (key == 0x3F) {//Handle F5 key hour = 0; minute = 0; second = 0; } else if (key != ' ') {//Handle invalid key printf("\033[1;50HInvalid Key: %c", key); } Sleep(sleep_time);//Rest for sleep_time ms second++; } second = 0; minute++; } minute = 0; hour++; } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started