Expert answer:c++ – lab

  

Solved by verified expert:Hello,I am working on a lab and I am half way done. I need someone to finish my program. I am submitting a text file where you can find the cpp files and h files necessaries to finish the lab.Thank you,
lab8.txt

lab_8_assignment.docx

Don't use plagiarized sources. Get Your Custom Essay on
Expert answer:c++ – lab
Just from $10/Page
Order Essay

Unformatted Attachment Preview

Account. cpp
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
Account::Account()
{
balance = 0.0;
}
int Account::getAccountNum()
{
return accountNum;
}
string Account::getAccountType()
{
return type;
}
double Account::getBalance()
{
return balance;
}
void Account::deposit(double amount)
{
balance += amount;
}
void Account::withdrawal(double amount)
{
balance -= amount;
}
Account.h
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include
using namespace std;
// Prevent multiple includes of this class
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
protected:
// The identifying number of the account
int accountNum;
// The total amount of money stored in the account
double balance;
// The type of account
string type;
public:
// Default constructor
Account();
// Returns the account number
int getAccountNum();
// Returns the account type
string getAccountType();
// Returns the amount of money stored
double getBalance();
// Applies an interest rate to the balance
virtual void accrueInterest() = 0;
// Adds money to the bank account
virtual void deposit(double amount);
// Removes money from the bank account
virtual void withdrawal(double amount);
};
#endif
CertificateOfDeposit.cpp
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
#include “CertificateOfDeposit.h”
// Constructor
CertificateOfDeposit::CertificateOfDeposit(int newAccountNum)
{
}
// Applies an interest rate to the balance
void CertificateOfDeposit::accrueInterest()
{
}
// Removes money from the bank account
void CertificateOfDeposit::withdrawal(float amount)
{
}
CertificateOfDeposit.h
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
// Prevent multiple includes of this class
#ifndef CERTIFICATEOFDEPOSIT_H
#define CERTIFICATEOFDEPOSIT_H
class CertificateOfDeposit
{
private:
bool hasWithdrawn;
public:
// Constructor
CertificateOfDeposit(int newAccountNum);
};
// Applies an interest rate to the balance
void accrueInterest();
// Removes money from the bank account
void withdrawal(float amount);
#endif
CheckingAccount.cpp
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
#include “CheckingAccount.h”
// Constructor
CheckingAccount::CheckingAccount(int newAccountNum)
{
}
// Applies an interest rate to the balance
void CheckingAccount::accrueInterest()
{
}
CheckingAccount.h
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
// Prevent multiple includes of this class
#ifndef CHECKINGACCOUNT_H
#define CHECKINGACCOUNT_H
class CheckingAccount
{
public:
// Constructor
CheckingAccount(int newAccountNum);
// Applies an interest rate to the balance
void accrueInterest();
};
#endif
Input.text
NEW CHECKING 101
NEW SAVINGS 102
NEW CERTIFICATE 103
DEPOSIT 101 75.00
DEPOSIT 102 25.00
DEPOSIT 103 100.00
DEPOSIT 101 10.00
WITHDRAWAL 101 15.00
WITHDRAWAL 102 10.00
TRANSFER 103 101 25.00
NEW CERTIFICATE 104
DEPOSIT 104 500.00
INTEREST
DEPOSIT 102 50.00
NEW CHECKING 105
DEPOSIT 100 100.00
WITHDRAWAL 101 5.00
WITHDRAWAL 101 5.00
DEPOSIT 101 5.00
WITHDRAWAL 101 5.00
INTEREST
DEPOSIT 105 43.00
DEPOSIT 104 31.00
WITHDRAWAL 102 9.00
NEW CERTIFICATE 106
DEPOSIT 106 100.00
DEPOSIT 106 4.00
INTEREST
NEW SAVINGS 107
DEPOSIT 107 195.00
NEW SAVINGS 108
DEPOSIT 108 199.00
WITHDRAWAL 101 45.00
DEPOSIT 107 50.00
WITHDRAWAL 108 91.00
DEPOSIT 106 182.00
INTEREST
Lab8.cpp
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
#include “CertificateOfDeposit.h”
#include “CheckingAccount.h”
#include “SavingsAccount.h”
#include
#include
using namespace std;
int main()
{
// File I/O
ifstream fin(“input.txt”);
ofstream fout(“output.txt”);
// Stores up to 30 accounts
Account* accounts[30];
// Number of accounts that have been opened
int numAccounts = 0;
// For file input processing
string command, acctType;
int acctNum1, acctNum2;
double amount;
// Do the input and math
while(fin >> command)
{
if(command == “NEW”)
{
// Create a new account
}
else if (command == “WITHDRAWAL”)
{
// Remove money from an account
}
else if (command == “DEPOSIT”)
{
// Add money to an account
}
else if (command == “TRANSFER”)
{
// Move money from one account to another
}
else if (command == “INTEREST”)
{
// Calculate interest on all accounts
}
}
// Print output
fout << "BANK STATEMENT" << endl << endl; for(int i = 0; i < numAccounts; i++) { fout << "Account number: " << accounts[i]->getAccountNum() << endl; fout << "Type of account: " << accounts[i]->getAccountType() << endl; fout << "Balance: $" << accounts[i]->getBalance() << endl; fout << endl; } // Delete accounts for (int i = 0; i < numAccounts; i++) delete accounts[i]; // Close files fin.close(); fout.close(); return 0; } output.txt BANK STATEMENT Account number: 101 Type of account: Checking Balance: $40 Account number: 102 Type of account: Savings Balance: $56 Account number: 103 Type of account: Certificate of Deposit Balance: $109.808 Account number: 104 Type of account: Certificate of Deposit Balance: $769.56 Account number: 105 Type of account: Checking Balance: $43 Account number: 106 Type of account: Certificate of Deposit Balance: $326.04 Account number: 107 Type of account: Savings Balance: $247.45 Account number: 108 Type of account: Savings Balance: $109.08 SavingsAccount.cpp // Txomin Chivite Amigo // 4-06-18 // Lab 8 #include "Account.h" #include "SavingsAccount.h" // Constructor SavingsAccount::SavingsAccount(int newAccountNum) { accountNum = newAccountNum; type = "Savings"; } // Applies an interest rate to the balance void SavingsAccount::accrueInterest() { if (balance >= 100.00 && balance < 1000.00) balance *= 1.01; else if (balance >= 1000.00)
balance *= 1.02;
}
SavingsAccount.h
// Txomin Chivite Amigo
// 4-06-18
// Lab 8
#include “Account.h”
// Prevent multiple includes of this class
#ifndef SAVINGSACCOUNT_H
#define SAVINGSACCOUNT_H
class SavingsAccount
{
public:
// Constructor
SavingsAccount(int newAccountNum);
// Applies an interest rate to the balance
void accrueInterest();
};
#endif
Lab #8
This week we will be working with different bank accounts. For this lab, we will have checking, savings,
and certificate of deposit (or CD) accounts.
About the accounts
Checking accounts:
• Can withdrawal and deposit money normally
• Do not gain interest
Savings accounts:
• Can withdrawal and deposit normally
• Gain 1% interest if they have $100.00 – 999.99
• Gain 2% interest if they have $1000.00 or more
Certificate of Deposits (CDs):
• Can deposit normally
• Tracks if money has been withdrawn
• Gain 10% interest if they haven’t been withdrawn
• Gain 1% interest if they have been withdrawn from
Structure
The base class is pretty simple on it’s own. The Account class is provided. But other derived classes all
need to inherit the methods and properties of the Account class.
Ex: having a Rectangle class inherit from a Shape class:
Class Rectangle : public Shape { … }
We will use an array of pointers to Accounts to store these. Depending on the type of account we need,
we’ll insert a new account in that point of the array. This won’t normally work, but using polymorphism,
and setting up our accounts to inherit from a base Account class, then any subclass we define will
actually also be a type of the base class.
Ex: Creating a new checking account:
Account *newAccount;
newAccount = new CheckingAccount(123);
Input
The input file consists of multiple lines of commands. These tell the program what to do.
If the line starts with NEW, then it creates a new account of the next word’s type (CHECKING, SAVINGS,
or CERTIFICATE). Then it creates it with the account number provided after that.
If the line starts with DEPOSIT, then it deposits into the account (listed next) the amount (listed after
that).
If the line starts with WITHDRAWAL, then it withdraws from the account (listed next) the amount (listed
after that).
If the line starts with INTEREST, we apply interest to all of the accounts. (Telling a checking account to
gain interest will run, but it doesn’t do anything.)
If the line starts with TRANSFER, transfer from the first account number to the second account number
the amount listed after that.
See the provided input.txt to see how the file looks.
Output
Print out the line “BANK STATEMENT” with an extra empty line. Then print out the account number,
type, and balance in this format:
Account number: 101
Type of account: Checking
Balance: $40
Leave a blank line between each account.
Grading and Turning In
Turn in your program before the end of the lab. Only upload the .cpp and .h files. Grading will be
performed using an automated grading program with a different input file (still input.txt) and will be
compared to an output file (output.txt). The lab instructor will still manually look at your code for the
other grading criteria (functional composition, style, etc.)

Purchase answer to see full
attachment

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 30% with the discount code ESSAYSHELP