boys and girls, I thank you in advance for your help. C++ issues . I have university assignment struggles
My Question: Below is my code that is not working can anybody help me to make it work? and what am I missing? (i have a feeling im missing a lot)
I have the functions and structs in separate header files and the “int main” in a .ccp. im using vis studio to do this. Please don’t think I’m trying to get others to do my assignment. Below is my code followed by the assignment task sheet (for further information purposes only). ODE
>
> // the int main must be my output to screen
> int main()
> {
> Customer* Mary = CreateCustomer("Mary Jones", "235718", "5074");
> Customer* John = CreateCustomer("John Smith", "375864", "3251");
> Account* MaryAccount = CreateAccount(*Mary, "06-3121-10212357", "01/03/2014", 100);
> Account* JohnAccount = CreateAccount(*John, "06-3121-10213758", "10/03/2014");
> RecordWithdraw(MaryAccount, CreateTransaction("01/03/2014", "ATM Withdrawal", 50) );
> RecordDeposit(MaryAccount, CreateTransaction("02/03/2014", "Deposit", 90) );
> RecordWithdraw(MaryAccount, CreateTransaction("04/03/2014", "ATM Withdrawal", 150) );
> RecordDeposit(MaryAccount, CreateTransaction("05/03/2014", "Deposit", 20) );
> RecordWithdraw(MaryAccount, CreateTransaction("05/03/2014", "Withdraw", 100) );
> RecordWithdraw(MaryAccount, CreateTransaction("05/03/2014", "Withdraw", 50) );
> RecordDeposit(JohnAccount, CreateTransaction("11/03/2014", "Deposit", 20) );
> RecordDeposit(JohnAccount, CreateTransaction("12/03/2014", "Deposit", 80) );
> RecordWithdraw(JohnAccount, CreateTransaction("12/03/2014", "Withdraw", 50) );
> PrintReport(MaryAccount);
> PrintReport(JohnAccount);
> return 0;
> }
>
> // the .h file as a struct ass1 section CUSTOMER
>
> #ifndef CUSTOMER_H
> #define CUSTOMER_H
>
> using namespace std;
>
> struct customer
> {
> std::string name;
> std::string pin;
> std::string user_id
> };
>
>
> // function for the above CUSTOMER
>
> Customer* CreateCustomer(const string& name, const string& id, const string& pin) {
> return new Customer { name, id, pin };
>
> }
>
>
> // the .h file as a struct ass1 section transaction
>
> struct Transaction
>
> {
> std::string date;
> std::string description;
> double amount;
> };
>
>
>
> // function for the above transaction
>
>
> transaction* CreateTransaction(const string& date, const string& description, const double& amount) {
>
> return new transaction { date, description, amount };
>
> }
>
>
> // the .h file as a struct ass1 section account
>
>
> struct Account {
> Customer customer;
> int number;
> double balance, total_deposit, total_withdrawal;
>
> // function for the above account
>
> //CreateAccount prototype:
>
>
> Account* CreateAccount(const Customer& customer, const std::string& openingDate = "01/01/2014", const double& openingBalance
> = 0, const double& deposit = 0, const double& withdraw = 0);
The Customer structure (defined in a header file Customer.h) containing three members: Customer Name, User ID and Pin.
A function CreateCustomer() that creates a Customer. It has three parameters to initialise each member of the structure (Customer Name, User ID, and PinNumber). All parameters should have default parameter blank values are to be specified. Prototype:
Customer* CreateCustomer(const string& name, const string& id, const string& pin)
The Transaction structure (defined in a header file Transaction.h) containing three members: Transaction Date, Description and Amount. The Amount can’t be negative value.
A function CreateTransaction() that creates a Transaction. It has three parameters to initialise each member of the structure (Transaction Date, Description and Amount). All parameters should have default parameter values are to be specified. The Date sets to "01/01/2014", the Description is blank and amount is zero. Prototype:
The Account structure (defined in a header file Account.h) containing seven members: Account Holder, Number, Balance, Total Deposit, Total Withdrawal, Transaction List array of maximum 100 records and Transaction count on the existing transaction records.
A function CreateAccount() that creates an Account. It has six parameters to initialise each appropriate member of the structure. The date parameter use to create the first transaction for the Transaction List array, the description is Opening balance from the balance parameter. Therefore, the Transaction count should be set to one after the Account is created. All parameters from the third one should have default parameter values are to be specified. The Date sets to "01/01/2014", the balance, deposit and withdraw set to zero value. Prototype:
A function RecordDeposit() that store the Transaction parameter into the Transaction List array of the parameter Account and increasing the Transaction count by one. Make sure to check the transaction parameter must have the amount higher than zero. Otherwise, display an error message. There is no requiring for the default parameter values. void RecordDeposit(Account* account, Transaction* transaction)
A function RecordWithdraw() that store the Transaction parameter into the Transaction List array of the parameter Account and increasing the Transaction count by one. Make sure to check the transaction parameter must have the amount higher than zero and less than or equal to the parameter account balance. Otherwise, display an error message. There is no requiring for the default parameter values.
A function PrintReport() that accepts an Account pointer parameter to display the summary balance account and the list of Transaction record on the array to displays as the provided output format. Prototype:
void PrintReport(Account* account)