-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
51 lines (43 loc) · 2.52 KB
/
main.c
File metadata and controls
51 lines (43 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "NumberSystemWizards_v2.c"
/* This is a number system converter supports converting from and to (bin, oct, dec, hex) */
int main(){
COLOR_INIT
WelcomeScreen(); // Display welcome screen and get the user name
bool flag = 1;
do{
int chosenSystem = beginningFunction(); // begin program and print the conversion list for the user to choose from
int makeSure = getMakeSure(); // To make sure he chose the desired system.
// 1 means the user meant to choose that system.
// 2 means the user want to change what he chose.
if(makeSure == 2){ //return back to the list
system("cls"); // To clear the screen.
continue; // To return back to the list.
}
else if (makeSure == 1){ // The user meant to chose that system.
if (chosenSystem == 5){ // If he chose to exit the program, display the closing message and exit the loop
displayClosingMessage();
break;
}
else { // The user doesn't want to exit the program, we enter another loop to get the input number to convert
do{
getInputNumberAndConvert(chosenSystem); // Get the input number from the user, validate it, and print its conversions
char response = optionList(chosenSystem); // Prompt the user to convert another number of the same system, return to the list, or to exit
if (response == 'N' || response =='n') { // The user want to exit the program
displayClosingMessage(); // Display the closing message and exit the loop
flag = 0; // Set to 0 to exit the parent loop
break;
}
else if (response == 'R' ||response == 'r'){
system("cls"); // To clear the screen and try again.
break;
}
// Else if (response =='y'|| response =='Y')
// He want to try that system again
// No need to write another else, the other 2 above are sufficient
}while(flag);
}
}
}while(flag); // Loop the program again until the user enter (N,n) or (5) in the first list.
printf("Press Enter to exit..."); getchar(); // To stop the terminal from disappearing after the closing display
return 0;
}