Question: Hi My program does seem to working to well 1) in the fuction newCustomer under the function getAddress when i enter street name and space

Hi My program does seem to working to well

1) in the fuction newCustomer under the function getAddress when i enter street name and space to add ave or street it skip to the next line

2) in display customer it completely crashes the program becuase something wasn't initalize

3) in SearchbyAccountNum nothing displays however i was trying to search by customer first name but it wasn't working

thank YOu

#define _CRT_SECURE_NO_WARNINGS

#define PAUSE system("pause")

#define CLS system("cls")

#define FLUSH flush();

#define SIZE 1000

#include

#include

#include

#include

#include

typedef struct{

char firstName[50];

char lastName[100];

char middleI;

int dob;

} PERSON;

typedef struct{

int houseNum;

char streetName[100];

char city[50];

char stateIn[2];

int zipcode;

} ADDRESS;

typedef struct{

PERSON person;

ADDRESS address;

int accountNumber;

float balance;

float deposit;

float withdraw;

}BANK;

// Prototype Function

BANK* createAccount(void);

void banking(BANK* account, int count);

void newCustomer(BANK* account, int *count);

void flush(void);

void freeMem(BANK* account[],int count);

void getAddress(BANK* account);

void getName(BANK* account);

void accountNumber(BANK* account);

void displayCustomers(BANK* account[],int count);

void deposit(BANK* account);

void withdraw(BANK* account);

void sort(BANK* account[], int count);

void searchByAccountNum(BANK* account[], int count);

char userChoice(void);

int main() {

BANK** account;

int count = 0;

char choice = ' ';

//Allocate Memory

account = calloc(SIZE, sizeof(BANK*));

do{

choice = userChoice();

switch(choice){

case 'E':// Add new Customer

account[count] = createAccount();

newCustomer(account[count],&count);

PAUSE;

break;

case 'B': // banking menu

banking(account, count);

PAUSE;

break;

case'D': // Display all customers sorted

displayCustomers(account, count);

PAUSE;

break;

case 'S': // Search for customer by account number

searchByAccountNum(account, count);

PAUSE;

break;

case 'Q': // Quit

printf("Thank You for Using my Program");

freeMem(account, count);

PAUSE;

break;

default:

printf("INVAILD SELECTION");

break;

}// end switch case

}while(choice != 'Q');

}// end main

void newCustomer(BANK* account, int *count){

CLS;

getName(account);

getAddress(account);

accountNumber(account);

}// end newCustomer

void displayCustomers(BANK* account[],int count){

CLS;

int i;

sort(account, count);

printf("Acct NO.\t First Name\t LastName\t address ");

for(i = 0; i < SIZE; i++){

printf("%i\t %s\t\t %s\t %i %s %s %s %i ",account[i]->accountNumber, account[i]->person.firstName, account[i]->person.lastName, account[i]->address.houseNum, account[i]->address.streetName, account[i]->address.city, account[i]->address.stateIn, account[i]->address.zipcode);

PAUSE;

}// end for loop

}// end Display Customer

void displayMenu(){

CLS;

printf("================================ ");

printf("======= M A I N M E N U ======= ");

printf("================================ ");

printf("[E]nter new customer ");

printf("[B]anking Menu ");

printf("[D]isplay customer ");

printf("[S]earch for customer by account number ");

printf("[Q]uit ");

printf("Enter Your Selection: ");

}// end displayMenu()

void freeMem(BANK* account[],int count){

int i;

for(i = 0; i < count; i++){

printf("%i. %p has been release ", i, account[i]);

free(account[i]);

}// end for

printf("The Array At %p is free ", account);

free(account);

}// end freeMem

void getName(BANK* account){

char person[100];

printf("Enter your first name: ");

scanf("%s",person);

person[0]=toupper(person[0]);

strcpy(account->person.firstName, person);

printf("Enter middle initial: ");

scanf(" %c", &account->person.middleI);

printf("Enter Your Last Name: ");

scanf("%s", person);

person[0] = toupper(person[0]);

strcpy(account->person.lastName, person);

}// end getName

void getAddress(BANK* account){

char address[50];

char city[15];

printf("Enter Customer Address ");

printf("House Number: ");

scanf("%i",&account->address.houseNum);

printf("Enter Street Name: ");

scanf(" %s ", address);

address[0]=toupper(address[0]); // convert to upper case

strcpy(account->address.streetName, address);

printf("Enter City: ");

scanf("%s", city);

address[0] = toupper(address[0]);

strcpy(account->address.city, city);

printf("Enter State Intitals: ");

scanf("%c",account->address.stateIn);

FLUSH;

printf("Enter Zipcode: ");

scanf("%i", &account->address.zipcode);

FLUSH;

}// end get address

void searchByAccountNum(BANK* account[], int count){

CLS;

int search;

int i;

printf("Enter the account Number to search: ");

scanf("%i" ,&search);

FLUSH;

for(i = 0; i < count; i++){

if(account[i]->accountNumber == search)

printf("%i\t %s\t\t %s\t %i %s %s %s %i ",account[i]->accountNumber, account[i]->person.firstName, account[i]->person.lastName, account[i]->address.houseNum, account[i]->address.streetName, account[i]->address.city, account[i]->address.stateIn, account[i]->address.zipcode);

}// end for loop

}// end searchByAccountNum

void sort(BANK* account[], int count){

int i, j;

BANK temp;

for(i = 0; i < count; i++)

for(j = i+1; j < count; j++){

if(strcmp(account[i]->person.firstName, account[j]->person.firstName) > 0){

temp = *account[i];

*account[i] = *account[j];

*account[j]= temp;

}// end if statement

}// end for loop

}// end sort

void accountNumber(BANK* account){

printf("Create your personal account Number (5 digit): ");

scanf(" %i", &account->accountNumber);

}// end account number

void flush(){

while(getchar() != ' ');

}// end flush

BANK* createAccount(){

BANK *result;

result = malloc(sizeof(BANK));

return result;

}// end createAccount

void bankMenu(BANK* account){

int no;

printf("Enter Account Number to begin banking: ");

scanf("%i", &no);

CLS;

printf("=========================== ");

printf("======== ACCOUNT MENU ===== ");

printf("=========================== ");

printf("Current Balance: $%.2lf ", account->balance);

printf("============================ ");

printf("1. Deposit ");

printf("2. Withdraw ");

printf("3. Return to Main Menu ");

printf("Enter Your Selection: ");

} // end bankMenu

void banking(BANK* account, int count){

int accountChoice;

do{

bankMenu(account);

scanf("%i", &accountChoice);

FLUSH;

CLS;

printf("Your current balance:$%.2lf ", account->balance);

switch (accountChoice) {

case 1:

deposit(account);

break;

case 2:

withdraw(account);

break;

}// end switch

}while( accountChoice != 3);

}// end banking

void deposit(BANK* account){

printf("How much do you want to add:$ ");

scanf("%f", &account->deposit);

FLUSH;

account->balance += account->deposit;

printf(" New Balance: $%.2lf ", account->balance);

PAUSE;

}// end deposit

void withdraw(BANK* account){

printf("How much do you want to withdraw:$ ");

scanf("%f", &account->withdraw);

FLUSH;

if (account->withdraw >= account->balance){

printf(" No Money to Withdraw ");

account->balance = 0;

} else {

printf(" You have Withdraw: $%.2lf", account->withdraw);

account->balance -= account->withdraw;

}//end if-else statement

}// end withdraw

char userChoice(){

char result;

displayMenu();

scanf(" %c", &result);

FLUSH;

return toupper(result);

}// end userChoice

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!