|
|
@ -1,62 +1,44 @@ |
|
|
|
#include"mainMenu.h" |
|
|
|
|
|
|
|
|
|
|
|
bool agePermission(int age){ |
|
|
|
bool agePermission(int age) |
|
|
|
{ |
|
|
|
|
|
|
|
if(age >= 18) |
|
|
|
{ |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
return age >= 18; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool checkIfInteger(char* input){ |
|
|
|
|
|
|
|
char *end_pointer; |
|
|
|
|
|
|
|
strtol(input, &end_pointer, 10); |
|
|
|
|
|
|
|
if (end_pointer == input || *end_pointer != '\0') |
|
|
|
{ |
|
|
|
bool checkIfInteger(char* userInput) |
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
char *endPointer; |
|
|
|
|
|
|
|
} |
|
|
|
/*the endPointer points to the first non-integer character signaled to stop conversion*/ |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
strtol(userInput, &endPointer, 10); |
|
|
|
|
|
|
|
return true; |
|
|
|
return !(endPointer == userInput || *endPointer != '\0'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
void ageInput(){ |
|
|
|
void ageInput() |
|
|
|
{ |
|
|
|
|
|
|
|
char input[20]; |
|
|
|
char* input_pointer; |
|
|
|
char* userInput = malloc(20*sizeof(char*)); |
|
|
|
char* userInputPointer; |
|
|
|
|
|
|
|
long age; |
|
|
|
|
|
|
|
printf("\nPlease specify your age : "); |
|
|
|
scanf("%s",input); |
|
|
|
scanf("%s",userInput); |
|
|
|
|
|
|
|
|
|
|
|
while (true) |
|
|
|
{ |
|
|
|
age = strtol(input,&input_pointer,10); |
|
|
|
age = strtol(userInput,&userInputPointer,10); |
|
|
|
|
|
|
|
if(checkIfInteger(input) == true && agePermission(age)== true) |
|
|
|
if((checkIfInteger(userInput))&& (agePermission(age))) |
|
|
|
{ |
|
|
|
age = strtol(input,&input_pointer,10); |
|
|
|
//age = strtol(userInput,&userInputPointer,10); |
|
|
|
|
|
|
|
printf("Access granted!\n\n\n\n"); |
|
|
|
|
|
|
@ -66,7 +48,7 @@ void ageInput(){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(checkIfInteger(input) == true && agePermission(age)== false) |
|
|
|
else if((checkIfInteger(userInput)) && !(agePermission(age))) |
|
|
|
{ |
|
|
|
|
|
|
|
printf("You should be at least 18 years old to create a bank account!\n"); |
|
|
@ -79,7 +61,7 @@ void ageInput(){ |
|
|
|
{ |
|
|
|
printf("input invalid! try again!\n"); |
|
|
|
|
|
|
|
scanf("%s",input); |
|
|
|
scanf("%s",userInput); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -88,7 +70,8 @@ void ageInput(){ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void showMenu(){ |
|
|
|
void showMenu() |
|
|
|
{ |
|
|
|
|
|
|
|
printf("\t\t\t\t\t\t\t Welcome to Bank Manager!"); |
|
|
|
printf("\n\n\n\n\t\t\t\t\t\tPlease select one of the following functions!"); |
|
|
|