Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program that can manage checking and savings accounts. Requirements: - The program can keep track of a maximum of 1 0 accounts.

Write a C program that can manage checking and savings accounts.
Requirements:
- The program can keep track of a maximum of 10 accounts.
- The program can create a bank account.
o It takes the following fields:
Account number should be a 4-digit integer (ex) a number between 1000
and 9999.
If the account number is already used by another account, the
program needs to ask a diOerent account number.
Account type (checking or savings)
You need to check the user input.
Holder name
The maximum length of the name is 30 characters.
Open date (string, format: YYYY-MM-DD)
You need to check the user input format.
Balance
Hint: Use a structure.
- The program can deposit money into a bank account.
o The program prints out the remaining balance.
The format string is %-15.2f.
- The program can withdraw money from a bank account.
o The program prints out the remaining balance.
The format string is %-15.2f.
- The program can sort accounts by diOerent fields and print them.
o Hint: Use qsort() function on Page 440 of the textbook.
o Sorting fields: account number, holder name, open date and balance.
o To print the holder name, the format string is %-30s.
o To print the balance, the format string is %15.2f.
- Hint: Refer to inventory.c on Page 391 of the textbook.
Example Interaction (user input is underlined; your program must follow this format
precisely without the underline):
$ gcc -Wall assignment6.c
$
$
$./a.out
******* Main menu *******
c(reate an account)
d(eposit money)
w(ithdraw money)
s(sort and print accounts)
q(uit program)
*************************
Enter operation code (c, d, w, s, q): c
Enter account number (4 digits): -20
Enter a number between 1000 and 9999.
Enter account number (4 digits): 12345
Enter a number between 1000 and 9999.
Enter account number (4 digits): 1111
Enter account type: c(hecking), s(avings)
c or s: d
Wrong account type. Enter c or s.
Enter account type: c(hecking), s(avings)
c or s: C
Enter account holder's name: John Smith
Enter open date (YYYY-MM-DD): 00000000
00000000 Wrong date format.
Enter open date (YYYY-MM-DD): 0000-00-00
0000-00-00 Wrong date format.
Enter open date (YYYY-MM-DD): 2024-7-1
2024-7-1 Wrong date format.
Enter open date (YYYY-MM-DD): 2024-07-01
Enter balance (number only): $ 5000.55
Account 1111 is created.
******* Main menu *******
c(reate an account)
d(eposit money)
w(ithdraw money)
s(sort and print accounts)
q(uit program)
*************************
Enter operation code (c, d, w, s, q): c
Enter account number (4 digits): 2222
Enter account type: c(hecking), s(avings)
c or s: S
Enter account holder's name: Emily Davis
Enter open date (YYYY-MM-DD): 2024-03-15
Enter balance (number only): $ 680.30
Account 2222 is created.
******* Main menu *******
c(reate an account)
d(eposit money)
w(ithdraw money)
s(sort and print accounts)
q(uit program)
*************************
Enter operation code (c, d, w, s, q): s
Enter the sorting field: a(ccount number), h(older name), o(pen date), b(alance)
a, h, o or b: a
#### Type Holder name Open date Balance
--------------------------------------------------------------------
1111 C John Smith 2024-07-015000.55
2222 S Emily Davis 2024-03-15680.30
--------------------------------------------------------------------
******* Main menu *******
c(reate an account)
d(eposit money)
w(ithdraw money)
s(sort and print accounts)
q(uit program)
*************************
Enter operation code (c, d, w, s, q): s
Enter the sorting field: a(ccount number), h(older name), o(pen date), b(alance)
a, h, o or b: h
#### Type Holder name Open date Balance
--------------------------------------------------------------------
2222 S Emily Davis 2024-03-15680.30
1111 C John Smith 2024-07-015000.55
--------------------------------------------------------------------
******* Main menu *******
c(reate an account)
d(eposit money)
w(ithdraw money)
s(sort and print accounts)
q(uit program)
*************************
Enter operation code (c, d, w, s, q): s
Enter the sorting field: a(ccount number), h(older name), o(pen date), b(alance)
a, h, o or b: o
#### Type Holder name Open date Balance
--------------------------------------------------------------------
2222 S Emily Davis 2024-03-15680.30
1111 C John Smith 2024-07-015000.55
--------------------------------------------------------------------
******* Main menu *******
c(reate an account)
d(eposit money)
w(ithdraw money)
s(sort and print accounts)
q(uit program)
*************************
Enter operation code (c, d, w

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions