Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class Account Private Data Members: static int genId int accountId double balance double annualInterestRate Static data member used to assign value to accountId; Account ID

Class Account

Private Data Members:

static int genId

int accountId

double balance

double annualInterestRate

Static data member used to assign value to accountId;

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)

Overloaded Constructor: 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()

static double getGenId()

Getters:

Function returns accountId

Function returns balance

Function returns annualInterestRate

Static Function used to returns genId

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. (IN C++)

When creating each Account object, make sure the object is initialized in both the default and overloaded constructor functions with following guidelines:

Each objects accountId should be the index of its position within the array. Add a static data member to initialize the accountId.

The balance of each Account object should be created from a random number generator functionreturning values between 100.00 and 200.00.

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

this program must separate the

Account class implementation from the main function file and, in addition, the Account class

must have its interface (Account.h) in a separate file from its implementation.

The code in the following files:

AccountMain.cpp

Account.cpp

Account.h -- provided in the attached file.

Main Program and remaining member function defintions:

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 the following options:

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 99 to exit to the main menu to select another account number.

Account.h

#pragma once class Account { private: static int genId; 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; static int getGenId(); //Function to get genId. //Postcondition: getId is returned. int getAccountId(); // Function to get accountId. // Postcondition: accountId is returned. double getBalance(); // Function to get balance. // Postcondition: balance is returned. double getInterest(); // Function to get 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; 

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions