Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming Write a program that satisfies the demands The output should look something like this.... This is my attempted code: contains errors, missing cases

C Programming

Write a program that satisfies the demands

image text in transcribed

The output should look something like this....

image text in transcribed

image text in transcribed

image text in transcribed

This is my attempted code: contains errors, missing cases and has not been completed. With the current code, can a program be made if added? If so, write a program that uses some of the functions to print the output.

OR

write a new program.

#include

typedef enum type{Savings,Cheque,Credit,Transaction}type;

struct account { char accid[10]; type acctype; char accbalance[50]; int accnom[4]; } ;

struct customer { char name[50]; char id[50]; struct account info; } ;

// put in memory location for number of accounts

int main() { int option = 0, i = 0, l = 0, m = 0; struct customer *p = malloc(sizeof(struct customer));

while (1) { printf(" "); printf("1. Add New Customer "); printf("2. Display All Customers "); printf("3. Search Cusomter By Name "); printf("4. Calculate Total Balances for a Customer "); printf("5. Calculate Total Balances "); printf("6. Exit "); printf(" "); printf("....Enter Your Choice....");

scanf("%d", &option);

switch (option) { case 1: p = realloc(p, sizeof(struct customer)*(i+1)); printf("a. Enter the customer details.... "); printf("b. Customer Name: "); scanf("%s", p[i].name); printf("c. Customer ID: "); scanf("%s", p[i].id); printf("d. How many accounts for the customer: "); scanf("%d", p[i].nomacc); switch (p[i].nomacc) { case 0: { printf("1"); } break;

case 1: { printf("2"); } }

printf(" ");

printf("Enter account ID: "); scanf("%s", p[i].info.accid); printf("Enter Account Type: "); scanf("%d", &p[i].info.acctype); printf("Enter Balance: "); scanf("%s", p[i].info.accbalance); i = i + 1; printf(" "); break;

case 2: for(l = 0; l

case 1: { printf("Cheque"); } break;

case 2: { printf("Credit"); }

case 3: { printf("Transaction"); } break; } printf(" "); printf("Account Balance: %s ", p[l].info.accbalance); } printf(" "); break;

case 6: return 0; }

}

return 0;

}

Customer Customer_ID Name Count of Accounts Ex: 1001 Amber 1 Ex: 1002 Aiden 2 Accounts Account_ID Customer_ID Ex: A1011001 Ex: A102 1002 Ex: A103 1002 Account Type Balance Savings 1200 Savings 1000 Cheque 800 The bank has approached you to develop a simple menu drive program to read and manage customers and account details. The bank has made the following requirements: a. The program should be menu-driven b. A customer could maintain zero (0) or more accounts C. Each account to be linked to a customer d. The types of accounts are Savings. Cheque, Credit, and Transaction e. Except for Savings, all other accounts can have negative balances f. Your program should be capable of creating and storing any number of customers with zero to four accounts for each customer g. Your program should have the facility to search customer by customer name h. Your program should have the facility to calculate the total balance across all the accounts for a customer i. Your program should have the facility to calculate the total balances across all the accounts j. The program should have the facility to display all customers and account details As part of this assessment, you are required to develop a C-language-based program to fulfil the above requirements. Your program should be based on the following instructions: a. Use appropriate C-language constructs to create customer records - Structures b. Use appropriate C-language constructs to create account records - Nested Structures C. Ensure your approach allows a customer to maintain 0 or many accounts d. Use enum to create account types e. Use dynamic memory allocation to create and maintain any number of customers and accounts. f. Total balance calculation should be done using Recursive Function The main menu of your program should be: 1. Add new customer 2. Display all customer 3. Search customer by name 4. Calculate total balances for a customer 5. Calculate total balances 6. Exit Enter your choice--1 On selection of option: 1, the following details to be collected a. Enter the customer details: b. Customer Name: C. Customer ID: d. How may accounts for the customer Based on the input to option d, the program should read policy details a. Enter account ID b. Enter account type C. Enter balance On selection of option two in the main menu: 1. Add new customer 2. Display all customers 3. Search customer by name 4. Calculate total balances for a customer 5. Calculate total balances 6. Exit Enter your choice--2 On selection of option 2, the program to display all the customers details and details of each account/s held by the customer. The output to be in the following format Customer Name: Amber Customer ID: 1001 Account ID: A101 Type: Savings Balance: 1200 Customer Name: Aiden Customer ID: 1002 Account ID: A102 Type: Savings Balance: 1000 Account ID: A103 Type: Cheque Balance: 800 On selection of option 3 in the main menu: 1. Add new customer 2. Display all customer 3. Search customer by name 4. Calculate total balances for a customer 5. Calculate total balances 6. Exit Enter your choice---3 On selection of option 3 from the main menu, the program to display the following options: Enter the name of the customer: Amber Details for Amber: Customer ID: 1001 Number of Accounts: 1 Account ID: 101 Type: Savings Balance: 1200 Enter the name of the customer: Helen Sorry, no details for Helen found. On selection of option 4 in the main menu: 1. Add new member 2. Display all members 3. Search member by name 4. Calculate total balances for a customer 5. Calculate total premium 6. Exit On selection of option 4 from the main menu, the program to display the total balances of all the accounts held by the customer. The total premium calculation should be implemented using Recursive Function Enter the name of the customer: Amber Total balance: 1200 Enter the name of the customer: Aiden Total balance: 1800 On selection of option 5 in the main menu: 1. Add new member 2. Display all members 3. Search member by name 4. Calculate total balances for a customer 5. Calculate total premium 6. Exit On selection of option from the main menu, the program to display the total balances of all the accounts. The total premium calculation should be implemented using Recursive Function Total balance: 3000 On selection of option 6 in the main menu: 1. Add new member 2. Display all members 3. Search member by name 4. Calculate total balances for a customer 5. Calculate total premium 6. Exit On selection of option 5, the program should terminate

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

Step: 3

blur-text-image

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Is SHRD compatible with individual career aspirations

Answered: 1 week ago