Question: Please see below (C++ Programming). Account.h file pasted below Write code using pointers and the Accounts class from week 1 assignment as follows create a
Please see below (C++ Programming). Account.h file pasted below
Write code using pointers and the Accounts class from week 1 assignment as follows create a program in which you
Create 10 accounts using an array with ids 0 to 9 and refer to each account using pointer notation
Add an initial balance of $100 to each account.
Write an interactive program (function if you prefer) in which the program should prompt the user enter a user id and password. If the id and password are not entered incorrectly, ask the user to do it again. Once id and password is accepted display a menu which gives the user the ability to
(i) view their accounts balance,
(ii) withdraw money,
(iii) deposit money, and
(iv) exit the menu.
d. After menu exit, prompt for a new user id and password and start again.
Account.h file:
#pragma once
//Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include
using namespace std;
class Account
{
public:
//constructor
Account(string fName, string lName);
//methods
void debitFrom(double amt);
void creditTo(double amt);
double currentBalance();
private:
string firstName;
string lastName;
double balance;
};
//Constructor to set first name and last name
Account::Account(string fName, string lName)
{
firstName = fName;
lastName = lName;
balance = 0;
}
//Method to debit the amount from balance
void Account::debitFrom(double amt)
{
balance-=amt;
}
//Method to credit the amount to balance
void Account::creditTo(double amt)
{
balance += amt;
}
//Return balance
double Account::currentBalance()
{
return balance;
}
#endif ACCOUNT_H
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
