Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write Narratives and Pseudocodes for the following code above. the code is as followed: #include #include #include #include struct Customer{ char banknumber[10]; char firstname[20]; char

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Write Narratives and Pseudocodes for the following code above.

the code is as followed:
#include
#include
#include
#include
struct Customer{
char banknumber[10];
char firstname[20];
char lastname[20];
char ssnumber[20];
char dob[10];
int age;
char nationality[20];
char password[20];
int balance;
};
//Declare an array of 10 Customers
struct Customer customers[10];
int total = 0;
int authentication();
void welcomeCustomer(int i);
int askUserChoice1();
int askUserChoice2();
void addNewCustomer();
void showCustomer(int i);
void showAccountBalance(int i);
void depositMoney(int i);
void withdrawMoney(int i);
void goodbyeCustomer(int i);
int main() {
int user;
int choice = 1;
while(choice != 0){
choice = askUserChoice1();
switch(choice){
case 1:
user = authentication();
if(user == -1)
continue;
welcomeCustomer(user);
while (choice != 0){
choice = askUserChoice2();
switch (choice){
case 1:
showCustomer(user);
break;
case 2:
showAccountBalance(user);
break;
case 3:
depositMoney(user);
break;
case 4:
withdrawMoney(user);
break;
case 0:
goodbyeCustomer(user);
break;
}
}
choice = 1;
break;
case 2:
addNewCustomer();
break;
}
}
return 0;
}
int askUserChoice1(){
int choice = 0;
do{
printf(" 1. Login ");
printf(" 2. Add new Customer ");
printf(" 0. Exit ");
printf(" Enter Your Choice: ");
scanf("%d", &choice);
} while (choice 2);
return choice;
}
int askUserChoice2(){
int choice = 0;
do{
printf(" 1. Show My Details ");
printf(" 2. Show My Account Balance ");
printf(" 3. Deposit money ");
printf(" 4. Withdraw money ");
printf(" 0. Log out ");
printf(" Enter Your Choice: ");
scanf("%d", &choice);
} while (choice 4);
return choice;
}
int authentication(){
int i;
char username[20];
char password[20];
printf("Enter Username: ");
scanf("%s", username);
for(i = 0; i
if(strcmp(customers[i].banknumber, username) == 0){
printf("Enter Password: ");
scanf("%s", password);
if(strcmp(customers[i].password, password)==0){
printf("Login Successful ");
return i;
}
else{
printf("Wrong password ");
return -1;
}
}
}
printf("User not found ");
return -1;
}
void welcomeCustomer(int i){
printf("Welcome %s ! ", customers[i].firstname);
}
void addNewCustomer(){
char temp[20];
int i, used;
char ch;
printf("Enter First Name : ");
scanf("%s", customers[total].firstname);
printf("Enter Last Name : ");
scanf("%s", customers[total].lastname);
printf("Enter Social Security Number: ");
scanf("%s", customers[total].ssnumber);
printf("Enter Date Of Birth : ");
scanf("%s", customers[total].dob);
printf("Enter Age : ");
scanf("%d", &customers[total].age);
printf("Enter Nationality : ");
scanf("%s", customers[total].nationality);
printf("Enter Password : ");
for(i = 0; i
ch = getch();
if(ch == 13)
break;
customers[total].password[i] = ch;
ch = '*';
printf("%c", ch);
}
customers[total].password[i] = '\0';
//scanf("%s", customers[total].password);
printf(" Enter Confirm Password : ");
for(i = 0; i
ch = getch();
if(ch == 13)
break;
temp[i] = ch;
ch = '*';
printf("%c", ch);
}
temp[i] = '\0';
if(strcmp(customers[total].password, temp) != 0){
printf("Password does not match ");
return;
}
printf(" Enter Account Balance : ");
scanf("%d", &customers[total].balance);
used = 1;
while(used){
if(customers[total].firstname[0] >= 'A' && customers[total].firstname[0]
temp[0] = customers[total].firstname[0] + 32;
else
temp[0] = customers[total].firstname[0];
if(customers[total].lastname[0] >= 'A' && customers[total].lastname[0]
temp[1] = customers[total].lastname[0] + 32;
else
temp[1] = customers[total].lastname[0];
temp[2] = (char)(rand() % 10 + 48);
temp[3] = (char)(rand() % 10 + 48);
temp[4] = '\0';
used = 0;
for(i = 0; i
if(strcmp(customers[i].banknumber, temp) == 0)
used = 1;
}
}
strcpy(customers[total].banknumber, temp);
printf("New Customer added! Your Customer Number: %s ", customers[total].banknumber);
total++;
}
void showCustomer(int i){
printf("\tBank Number : %s ", customers[i].banknumber);
printf("\tFirst Name : %s ", customers[i].firstname);
printf("\tLast Name : %s ", customers[i].lastname);
printf("\tSocial Security Number: %s ", customers[i].ssnumber);
printf("\tDate Of Birth : %s ", customers[i].dob);
printf("\tAge : %d ", customers[i].age);
printf("\tNationality : %s ", customers[i].nationality);
}
void showAccountBalance(int i){
printf("Your Account Balance: %d ", customers[i].balance);
}
void depositMoney(int i){
int amount;
printf("Enter Deposit Amount: ");
scanf("%d", &amount);
customers[i].balance += amount;
}
void withdrawMoney(int i){
int amount;
printf("Enter Withdrawal Amount: ");
scanf("%d", &amount);
if(customers[i].balance
printf("You do not have sufficient balance ");
return;
}
customers[i].balance -= amount;
}
void goodbyeCustomer(int i){
printf("Goodbye, and come again %s ", customers[i].firstname);
}
Please write Narratives and Pseudocodes.
1 2 #include #include #include #include 1 000 struct Customer{ char banknumber[10]; char firstname[20]; char lastname[20]; char ssnumber [20]; char dob[10]; 10 11 12 int age; 13 14 char nationality [20]; char password[20]; int balance; 15 16 }; 17 18 //Declare an array of 10 Customers 19 struct Customer customers[10]; int total = 0; 20 21 22 23 24 25 26 int authentication(); void welcomeCustomer(int i); int askuserChoice1(); int askUserChoice2(); void addNewCustomer(); void showCustomer(int i); void showAccountBalance(int i); void depositMoney(int i); void withdrawMoney(int i); void goodbyeCustomer(int i); 27 28 29 30 31 351 37 32 33 int main() { 34 int user; int choice = 1; 36 while(choice != 0){ choice = askuserChoice1(); switch(choice) { case 1: 41 user = authentication(); if(user -1) continue; 38 3 39 40 1 42 43 44 As 45 welcomeCustomer(user); 46 47 48 49 50 5 51 52 53 54 while (choice != 0){ choice = askuserChoice2(); switch (choice) { case 1: showCustomer (user); break; case 2: showAccountBalance(user); break; case 3: depositMoney (user); break; case 4: withdrawMoney (user); break; case : 55 56 57 58 59 60 61 62 94 95 96 97 printf(" 1. Show My Details "); printf(" 2. Show My Account Balance "); printf(" 3. Deposit money "); printf(" 4. Withdraw money "); printf(" 0. Log out "); printf("Enter Your Choice: "); scanf("%d", &choice); } while (choice 4); 98 99 100 101 102 return choice; 103 104 } 105 106 107 int authentication() { int i; char username[20]; char password [20]; 108 109 110 111 printf("Enter Username: "); scanf("%s", username); 112 113 114 115 == 116 117 118 119 for(i 0; i = 'A' && customers [total].firstname[0] = 'A' && customers[total].lastname[0]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions