Question: I need this program in C++. I have coded out my best attempt at it but I am not sure I have done it correctly.

I need this program in C++. I have coded out my best attempt at it but I am not sure I have done it correctly. I couldn't figure out how to dynamically create the structure. Also, I'm sure there is a better way to validate that the account number is 5 digits long. I couldn't find another way to break out of the while loop without using a break, I would like to maybe see if there is a more efficient way for that.

Here is the details required of the program:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Develop an application using structures for a customer that will determine if he/she has exceeded his/her checking account balance. For each customer, the following facts are available: a. Name b. Address c. Account number (Five digits only, i.e. test for this) d. Balance at the beginning of the month e. Total of all checks written by this customer this month Loop until customer is through entering checks. f. Total of all deposits credited to this customer's account this month. Loop until customer is through entering deposits. Dynamically create the structure. The program should input each of these facts from input dialogs, store in a structure, calculate the new balance, display the new balance and debit the account $15 if overdrawn. Also, if overdrawn, tell the customer the additional $15 fee has been accessed and what the balance would be with this fee included. Make sure to output the contents of the structure. 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here is the structure I have in the .h file

#ifndef CUSTOMER_H #define CUSTOMER_H struct Customer { string name; // Customers Name string address; // Customers address int account; // Five digit account number float balance; // Balance at the beginning of the month float cTotal[]; // Total of all checks written by customer this month float dTotal[]; //Total of all deposits credited to the account this month };

#endif /* CUSTOMER_H */

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

And here is the main program I have so far:

#include #include #include using namespace std;

#include "Customer.h"

int main( ) {

cout<<"Bank Account(Problem 1)"<> input.account; int length = to_string(input.account).length(); while(length != 5) { cout << "Invalid account number. Please enter a 5 digit account " "number: "; cin >> input.account; int exit = to_string(input.account).length(); if(exit == 5) break; } cout << "Enter the account balance: "; cin >> input.balance; sum = sum + input.balance; cout <<"How many checks did you write this month?: "; cin >> checks; for(int i = 0; i < checks; i++) { cout << "Enter the amount for the current check: "; cin >> input.cTotal[i]; diff += input.cTotal[i]; } cout << "Total amount from checks: " << diff << endl; cout << "How many deposits would you like to enter for this month?: "; cin >> deposits; for(int i = 0; i < deposits; i++) { cout << "Enter the amount for the current deposit: "; cin >> input.dTotal[i]; sum += input.dTotal[i]; } cout <

return 0;

}

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!