100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Homework help on zylabs $4.99   Add to cart

Other

Homework help on zylabs

 0 view  0 purchase
  • Course
  • Institution

Source code for zylab question

Preview 2 out of 11  pages

  • November 20, 2021
  • 11
  • 2019/2020
  • Other
  • Unknown
avatar-seller
COMPUTER SCIENCE 2

ZYLABS

-Compare and contrast vector data type with arrays. Note difference in passing vectors as parameters.
They are explicitly passed as reference parameters.

-Create vectors of objects, using vector methods for size, adding elements, erasing elements, and using
iterators to traverse the data structure.

-Use exception handling in the form of try-catch blocks to take care of file access problems.

-Use of stringstream methods to parse input data

-Use the getline function to read data line by line from the file

Upgrade the BankAccount class to store accounts in a vector called accountsVector. Create a static
variable called count that stores the number of BankAccount objects created. Read data as before from
the same file BankData.dat and create objects accordingly and store them in the vector. You may need
to add or modify methods in your BankAccount class, as well as helper methods in your main class.

Use your homework 3 assignment in Zylabs to help you with this work. The data file is also uploaded.

Extend the BankAccount class to include a static int variable called count that stores the number of
objects created. Note you will need to use the scope resolution operator :: to accessthis variable.

BankAccount

-string accountName // First and Last name of Account holder

-int accountId // secret social security number

-int accountNumber // integer

-double accountBalance // current balance amount

+ static int count // number of objects created **

+ BankAccount () //default constructor that sets name to “”,

account number to 0 and balance to 0

+BankAccount (string accountName, int id, int accountNumber, double

accountBalance) // regular constructor

+getAccountBalance (): double // returns the balance

+getAccountName: string // returns name

+getAccountNumber: int

+setAccountBalance (double amount): void

+equals (BankAccount other): bool // returns true if this equals other. False

, otherwise **

+getCount (): int // returns count **

-getId (): void

+withdraw (double amount): bool //deducts from balance and returns true if resulting balance is less
than minimum balance.

+deposit (double amount): void //adds amount to balance. If amount is greater than rewards amount,
calls.

// addReward method

-addReward (double amount) void // adds rewards rate * amount to balance

+toString (): String // return the account information as a string with three

lines. “Account Name: “name

“Account Number:” number

“Account Balance:” balance

Create the specification file BankAccount.h which meets the above specifications. Create the
implementation file BankAccount.cpp which implements the BankAccount class as given in the UML
diagram above. The class will have member variables (attributes/data) and instance methods
(behaviors/functions that initialize, access and process data)

Create a driver class to do the following:

Read data from the given file BankData.data and create and vector of BankAccount Objects

The order in the file is first name, last name, id, account number, balance. Note that account name
consists of both first and last name.

Print the vector (without secret id) as in Homework3.

Find the account with largest balance and print it

Find the account with the smallest balance and print it.

Print the number of objects using static count variable as well as vector size method

Determine if there are duplicate accounts in the array. If there are then erase the account from the
vector. Note the difference in the method return value and the procedure to the equals method in
Homework 3. See how array deletion is different from vector deletion.

If there are duplications then reprint the vector as before. Again, print the number of objects using static
count variable as well as vector size method. See if there is a difference.

Insert three new accounts at position 3, 5 and 7 of the vectors. Remember your vector will keep
increasing in size as you add! The three accounts are:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Getrude. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $4.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83750 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$4.99
  • (0)
  Add to cart