Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Homework help on zylabs

Rating
-
Sold
-
Pages
11
Uploaded on
20-11-2021
Written in
2019/2020

Source code for zylab question

Institution
Course

Content preview

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:

Written for

Institution
Course

Document information

Uploaded on
November 20, 2021
Number of pages
11
Written in
2019/2020
Type
OTHER
Person
Unknown

Subjects

$5.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
Getrude

Also available in package deal

Get to know the seller

Seller avatar
Getrude Multimedia University
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 year
Number of followers
0
Documents
0
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions