From 5316faa364ee9041ab26ff349822c8141bf5b33b Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Sun, 29 Jan 2023 00:00:06 +0100 Subject: [PATCH] implement the functions ageInput() and showMenu() to execute mainMenu.c . --- src/main.c | 4 +++- src/mainMenu.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/mainMenu.h | 3 +++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 3f845e6..b37734e 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,8 @@ -#include +#include "mainMenu.h" int main() { + + ageInput(); return 0; } diff --git a/src/mainMenu.c b/src/mainMenu.c index 54d20ad..9cd19c0 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -39,4 +39,63 @@ bool checkIfInteger(char* input){ } } +void ageInput(){ + char input[20]; + char* input_pointer; + + long age; + + printf("\nPlease specify your age : "); + scanf("%s",input); + + + while (true) + { + age = strtol(input,&input_pointer,10); + + if(checkIfInteger(input) == true && agePermission(age)== true) + { + age = strtol(input,&input_pointer,10); + + printf("Access granted!\n\n\n\n"); + + showMenu(); + + break; + + } + + else if(checkIfInteger(input) == true && agePermission(age)== false) + { + + printf("You should be at least 18 years old to create a bank account!\n"); + + break; + + } + + else + { + printf("input invalid! try again!\n"); + + scanf("%s",input); + + } + + } + +} + + +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!"); + printf("\n\n\n\n\t\t\t\t\t\t ->Login as an existing costumer."); + printf("\n\n\t\t\t\t\t\t ->Register as a new costumer."); + printf("\n\n\t\t\t\t\t\t ->Login as an Employee."); + printf("\n\n\t\t\t\t\t\t\t\t ->Exit.\n"); + printf("\n\n\n\n\n Selection :\n"); + +} diff --git a/src/mainMenu.h b/src/mainMenu.h index 61192be..ccc7d9c 100644 --- a/src/mainMenu.h +++ b/src/mainMenu.h @@ -9,5 +9,8 @@ bool agePermission(int age); bool checkIfInteger(char* userInput); +void ageInput(); +void showMenu(); + #endif