Project# 1:

COP 3014 Spring 2018 [50 points]

This project also promises additional 15 bonus points. See Grading Notes

Policies (For all Deliverables)

File Names: project1main.cpp, project1exceptions.h, statistics.cpp, statistics.h, bankaccount.cpp, bankaccount.h

Goal: Requirement Specifications

We will first write a class that provides facilities for statistical computations (such as calculating sum, average, minimum, maximum, variance, and standard deviation) for data that is stored in an dynamically allocated array. Then you will use that class to implement applications that will use this “statistical package” for at least two vastly different application classes.

Functional Specifications

This project specifies three applications, you must implement the BankAccount Application, and have a choice of implementing the one of the other two applications as a Bonus.

Bank Account Specifications (Required)

This Application stores every transaction as soon as a transaction happens. Only amount of the transaction is stored, the date of transaction or any other data is not stored by this class.

When the application starts, it will ask the user about what is the maximum number of expected transactions. You will assume that the balance is zero when the program first starts.

The application will allow the user to make deposits as long as the balance is not above $100,000 FDIC limit.

The application will allow users to withdraw money as long as the withdrawal amount is no more than the available balance.

The application will allow the user to print the available balance at anytime.

The application will also allow the banker to print following statistics regarding the account at any time:

●balance

●total deposits

●total withdrawals

●average deposit amount

●average withdrawal amount

●minimum deposit amount

●minimum withdrawal amount

●maximum deposit amount

●maximum withdrawal amount

●variance of all the deposits

●variance of all the withdrawal

●standard deviation of all the deposits

●standard deviation of all the withdrawal

House Sales Partial Functional Specifications (Bonus) [5 points]

Let us say you find a consulting opportunity for a regional real-estate company that wants you to write a class to do statistical analysis that also keeps track of all the houses sold in your area.

When the application starts, it will ask the user about what is the maximum number of expected house sales. You will assume that no house has been sold when the program first starts.

They want you to store the sales price as soon as the house is sold. Only sale price is stored, the address or the date of sale or any other data is not stored by this class.

You must write your own functional specification to complete these partial specifications. [2 points]

You must provide your own detailed design for this class (model it after the BankAccount, noting that there is need for only one Statistics Object). [3 points]

Miles Driven Partial Functional Specifications (Bonus) [5 points]

Let us say that as a consultant you have to drive a lot to visit various customers. You want to write an App to simplify the calculations of miles driven so you can easily so you can get reimbursed at the end of the month. One class in this app will maintain miles for every business trip you make during the month.
When the application starts, it will ask the user about what is the maximum number of trips you are expected to make. You will assume that no trips have been made when the program first starts.
You want to store miles driven for every business trip as soon as a trip is completed. Only the miles drive are stored. The date of trip or any other data is not stored by this class.

You must write your own functional specification to complete these partial specifications. [2 points]

You must provide your own detailed design for this class (model it after the BankAccount, noting that there is need for only one Statistics Object). [3 points]

Design

All the three “Applications” will use object(s) of a common “utility” class called “Statistics” that will maintain a dynamically allocated array of doubles [5 points]. The data will be stored in that array.

Statistics Class [20 points]

This class will provide functions that are shown in the UML class diagram shown below. Their functionalities are obvious from their names, but ask is you are not sure about any one.

●The function add() adds a double value at the and of the array.

●The function get() obtains a copy of the value stored at the location i.

●The function set() overwrites (changes) the value stored at the location i by the provided value.

●The printStats() function invokes all other stats related functions and prints them on the screen.

Here are the functions in UML format so you can copy-n-paste

add(value: double): void

get(i: int): double

set(i: int, data: double): void

sum(): double

average(): double

min(): double

max(): double

var(): double

stdev(): double

printStats(): void

Here are the functions in UML format so you can copy-n-paste:

deposit(amount: double): void

withdrawal(amount: double): void

getBalance(): double

getTotalDeposits(): double

getTotalWithdrawals(): double

getAverageDeposit(): double

getAveragWithdrawal(): double

getMinDeposit(): double

getMinWithdrawal(): double

getMaxDeposit(): double

getMaxWithdrawa(): double

getVarOfDeposits(): double

getVarOfWithdrawal(): double

getStdevOfdeposits(): double

getStdevOfWithdrawal(): double

printAllStats(): void

#include "statistics.h"

class BankAccount{

public:

//...

private:

Statistics deposits; //the aggregation relationship

Statistics withdrawals; //the aggregation relationship

};

Bonus: MilesDriven or HouseSales Class Implementation [10 points]

To obtain full bonus points, in addition to the test() functions, you will be required to

provide an implementation of “process()” function that wraps full functionality for the user as you have specified. This will include user interactivity.

Implementation Notes

For every class, all error conditions (in functions where errors can take place) must be identified and exceptions must be written and thrown.

The exceptions must be “caught” only in the test() and process methods. [10 points]

For every class that you write, please implement a generic print() function [5 points] that prints all the data “owned” by that class directly or indirectly. Also implement static test() function that tests all other functions without any user input (all values that are otherwise expected from the user will be hard coded), and at least 5 new entries into the array.

Exceptions

All Exception classes can be written inside a single file called “myexceptions.h”. The constructors and functions of exception classes can be “inlined” like shown in the class. See lecture on Exceptions.

Let us have a discussion about Exceptions here. Please list the exceptions that you feel must be there below (I will start with one):