Question: The lab requires you to create two files Account.cpp and AccountMain.cpp. Account Class Definition: Class Account Private Data Members: int accountId double balance double annualInterestRate

The lab requires you to create two files Account.cpp and AccountMain.cpp.

Account Class Definition:

Class Account

Private Data Members:

int accountId

double balance

double annualInterestRate

Account ID

Current Balance of the account

Current Annual Interest Rate of the Account (ex. 4.5)

Public Member Functions:

Account()

Account(int id, double bal, double interest)

Constructors:

Default Constructor (no parameters)

Three-Parameter Constructor

Public Member Functions:

void setAccountId (int x)

void setBalance(double x)

void setInterest(double x)

Setters:

Function sets id to x

Function sets balance to x

Function sets annualInterestRate to x

Public Member Functions:

int getAccountId()

double getBalance()

double getInterest()

Getters:

Function returns accountId

Function returns balance

Function returns annualInterestRate

Public Member Functions:

double getMonthlyInterestRate()

Function calculates the monthly interest rate and returns the value

double getMonthlyInterest()

Function calculates the amount earned per month from interest and returns the value rounded to 2 decimal places. (Assume interest is not compounding)

Bool withdraw(double amount)

Function only allows withdraw if the current balance is greater than or equal to the withdraw amount. Return true if withdrawal is successful, else return false.

void deposit(double amount)

Function adds the amount passed as a parameter to the current balance.

Write a program that creates an array of 10 Account objects.

When creating each Account object use the following guidelines:

Each objects accountId should be the index of its position within the array.

The balance of each Account object should be created from a random number generator function returning values between 10,000.00 and 20,000.00. This return value should be rounded to two decimal places.

The interest rate of each Account object should be created from a random number generator function returning values between 1.5 and 5.0. This return value should be rounded to one decimal place.

The program should then ask the user to select an account number from 0 9 or -1 to exit the program.

If an account number is selected, then the user should be presented with some options. The five main bullets should form the menu presented. If a user makes any of the top five selections, then the menu should be represented. The menu should only not be represented with an entry of -1.

Enter 1 to make a deposit

Ask the user for the amount they wish to deposit

Enter 2 to make a withdraw

Ask the user for the amount they wish to withdraw

Return if withdrawal was successful or unsuccessful depending on function return value

Enter 3 to check balance

Display the accounts current balance

Enter 4 to check interest rate

Display the accounts monthly and yearly interest rate

Enter 5 to display account summary

Display account id, balance, monthly interest rate, and monthly interest amount

Enter -1 to return to the main menu

This will return the user to the main menu prompting to select an account number

I have the code already but I am unable to compile it due to the following messages n Accountmain

AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x117): undefined reference to `Account::Account()' \Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x1f4): undefined reference to `Account::Account(int, double, double)' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x249): undefined reference to `Account::~Account()' \AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x3d8): undefined reference to `Account::deposit(double)' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x442): undefined reference to `Account::withdraw(double)' \AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x497): undefined reference to `Account::getBalance()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x4f9): undefined reference to `Account::getMonthlyInterestRate()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x54f): undefined reference to `Account::getInterest()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x5d3): undefined reference to `Account::getBalance()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x629): undefined reference to `Account::getMonthlyInterest()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x67f): undefined reference to `Account::getMonthlyInterestRate()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x765): undefined reference to `Account::~Account()' AppData\Local\Temp\cc0Pa9v1.o:AccountMain.cpp:(.text+0x7a9): undefined reference to `Account::~Account()' z:/c++/dev-cpp/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe: AppData\Local\Temp\cc0Pa9v1.o: bad reloc address 0x188 in section `.rdata' z:/c++/dev-cpp/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation collect2.exe: error: ld returned 1 exit status

Compilation failed after 0.69 seconds with errors

This is the code I have

Account.h was provided:

#pragma once class Account { private: int accountId; double balance; double annualInterestRate; public: Account(); Account(int id, double bal, double interest); void setAccountId(int x); // Function to set accountId based on passed parameter. // Postcondition: accountId = x; void setBalance(double x); // Function to set balance based on passed parameter. // Postcondition: balance = x; void setInterest(double x); // Function to set annualInterestRate based on passed parameter. // Postcondition: annualInterestRate = x; int getAccountId(); // Function to set accountId. // Postcondition: accountId is returned. double getBalance(); // Function to set balance. // Postcondition: balance is returned. double getInterest(); // Function to set annualInterestRate. // Postcondition: annualInterestRate is returned. double getMonthlyInterestRate(); // Function to calculate the monthly interest rate. // Postcondition: Monthly interest rate is calculated and returned. double getMonthlyInterest(); // Function to calculate the amount that would be earned through monthly interest. // Postcondition: Amount that will be earned through monthly interest is calculated and returned. bool withdraw(double amount); // Function to reduce the account's current balance by the passed parameter, but only if the balance // is greater than the passed in parameter. If successful, return true, otherwise return false. // Postcondition: if (balance > amount) balance = balance - amount and return true; // otherwise return false; void deposit(double amount); // Function to increase the account's current balance by the passed parameter. // Postcondition: balance = balance + amount; }; 

Account.cpp

#include #include "Account.h"

using namespace std;

//ALL FUNCITIONS GO HERE

//Constructor Function

Account::Account() { } Account::Account(int id, double bal, double interest) { accountId = id; balance = bal; annualInterestRate = interest; } //Functions that sets to different values

void Account::setAccountId(int x) { int accountId = x; } void Account::setBalance(double x) { double balance = x; } void Account::setInterest(double x) { double annualInterestRate = x; } //Get Functions int Account::getAccountId() { return accountId; } double Account::getBalance() { return balance; } double Account::getInterest() { return annualInterestRate; } //Funcions that calculates double Account::getMonthlyInterestRate() { return annualInterestRate / 12; } double Account::getMonthlyInterest() { return (balance*(annualInterestRate / 12)) / 100; } bool Account::withdraw(double amount) { if (balance > amount) { balance = balance - amount; return true; } else { return false; }

} void Account::deposit(double amount) { balance = balance + amount; }

AccountMain.cpp

#include "Account.h" #include #include #include #include #include

using namespace std;

int main() { double max_balance=20000.00; double min_balance=10000.00; double max_intrest=5.0; double min_intrest=1.5;

//Declaring arrays

Account accountlist[10];

for(int i=0; i<10;i++){

float r = (float)rand() / (float)RAND_MAX;

double balance = min_balance + r * (max_balance - min_balance);

double annualInterestRate =min_intrest + r*(max_intrest - min_intrest);

accountlist[i] = Account(i,balance,annualInterestRate);

}

int accountId;

cout<<"Please enter an account number from 0-9: ";

cin>>accountId;

if(accountId < 0 || accountId > 9) { exit(0); }

else { // display menu item

do {

int choice;

double amount;

cout << "Enter 1 to make a deposit"; cout << "Enter 2 to make a withdraw"; cout << "Enter 3 to check balance"; cout << "Enter 4 to check interest rate"; cout << "Enter 5 to display account summary"; cout << "-1 to return to the main menu"; cin>>choice;

switch(choice) {

case 1 : cout<<"Enter amount to deposit :"; cin >> amount; accountlist[accountId].deposit(amount); break;

case 2 : cout<<"Enter amount to withdraw :"; cin >> amount; cout << accountlist[accountId].withdraw(amount); break;

case 3 : cout <<"Current Balance : ";cout << accountlist[accountId].getBalance(); break;

case 4 : cout<<"Monthly Interest Rate : "; cout << accountlist[accountId].getMonthlyInterestRate(); cout<<"Yearly Interest Rate : "; cout << accountlist[accountId].getInterest(); break;

case 5 : cout <<"Account Id : "+accountId; cout <<"Balance : "; cout<

default : cout<<"Please enter an account number from 0-9: "; cin>>accountId; if(accountId < 0 || accountId > 9) { exit(0); } } } while(true); } 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!