CS

Program Assignment
Use printf to ensure dollar values are rounded to two decimal places.
Investments (180 total)

The following program models an Investment Protfolio.  Please follow the model as described.
There are many different kinds of investments, including stocks, bonds, and bank accounts. There are two kinds of bank accounts: checking and savings. Design subclasses: Stock, Bond, and BankAccount, and its two subclasses SavingsAccount and CheckingAccount.

Investment (10)
Design an abstract Investment class that includes String type and String name attributes, and a  double investmentValue attribute. Each has an accessor and mutator method. There is also a toString method to print out the type and the name.
There is a default constructor that sets the type and name to none. 
There is also a two parameter constructor with the type and name. The Investment class, being abstract, cannot be instantiated.
There is also a toString method to print out the type and the name.

Stock (20)
The attributes of Stocks are pricePerShare, numOfSharesOwned, and dividendsEarnedToDate (a percent of the investment paid annually), as well as the inherited attributes.  These pricePerShare and numOfSharesOwned have accessors and mutators.
There is a default constructor that calls the super default constructor.
There is a constructor with name (of the stock), pricePerShare and numSharesOwned.
Calls super, hardcoding Stock for the type.
Calls mutators for the pricePerShare and numSharesOwned parameters.
Calls setInvestmentValue with the initial value of the investment as calculated from the other two parameters.
There is also a method calcStockValues with parameters of type double priceChange and dividendPercent. (Note: Based on stock is called periodically)
The pricePerShare increases or decreases by the priceChange (which could be positive or negative.
The currentDividend is calculated by the pricePerShare*dividendPercent/100.0
Increment the dividendsEarnedToDate as appropriate
If there was a profit indicated in this call use the dividend to buy additional shares and update the numOfSharesOwned.
Calculates the new total value of the investment and calls setInvestmentValue to set the value (It is simple to calculate new totalValue).
There is a toString method that uses super.toString to help print out the stock data in accord with the portfolioresults.txt file (found in the homework).

Bond (20)
The attributes of Bond are double pricePerBond, annualReturnPercentage, rate, cashEarnedToDate, and int numBondsOwned, as well as the inherited attributes. There are accessors and mutators for pricePerBond, numBondsOwned, and annualReturnPercentage.  The setAnnualReturnPercentage method also calculates the monthly rate of return (divide by 12. And 100.)
There is a default constructor that calls the super default constructor.
There is a constructor with name (of the bond), pricePerBond, numBondsOwned, and annualReturnPercentage.
Calls super, hardcoding Bond for the type.
Calls mutators for the pricePerBond, numSharesOwned and annualReturnPercentage parameters.
Calculates the new total value of the investment and calls setInvestmentValue to set the value (It is simple to calculate new totalValue)
There is a method calcBondValues with no parameters that assumes that it is being called on a monthly basis (for simplicity)
Calculates cashEarnedToDate by adding to the current cashEarnedToDate the value of one months worth of interest based on pricePerBond
Call setInvestmentValue as pricePerBond*numBondsOwned + cashEarnedToDate. (Note we arent reinvesting here like we did for Stock)
There is a toString method that uses super.toString to help print out the bond data in accord with the portfolioresults.txt file (found in the homework)

BankAccount (20)
BankAccount is an abstract class that extends Investment.  The name field holds the banks name. An additional String attribute accountNumber represents an account number. It also has the inherited attributes. This attribute has a mutator and an accessor. BankAccount has two subclasses: SavingsAccount and CheckingAccount.
There is a default constructor that calls the super default constructor. It also uses a mutator to set the  accountNumber to none.
There is a constructor with type, name and accountNumber.
Calls super with type and name
Call mutator to set the accountNumber.
There is a toString method that uses super.toString to help print out the BankAccount data (for the appropriate subclass in accord with the portfolioresults.txt file (found in the homework).

SavingsAccount (20)
A SavingsAccount is a sublass of a BankAccount. SavingsAccount has annualInterestRatePercent, rate(the prior value divided by 12 and by 100) and totalInterestEarned as instance variables as type double, as well as the inherited instance variables. Both annualInterestRatePercent and totalInterestEarned have accessors and mutators. The setAnnualInterestRatePercent method also calculates the rate of return (divide by100.0)
There is a default constructor that calls the super default constructor.
There is a constructor with name and accountNumber, the initialDeposit, and the annualInterestRatePercent.
Call super with “SavingsAccount”, bankName, and accountNumber.
Call setInvestmentValue to the initialDeposit.
Call setAnnualInterestRatePercent with the annualInterestRatePercent.
There is a method makeDeposit with a double deposit input parameter that uses setInvestmentValue to update the amount in the account.
There is a method makeWithdrawal with a double withdrawal input parameter that checks if there are sufficient funds to withdraw. If there arent dont make a withdrawal but print a message stating insufficient funds. Otherwise uses setInvestmentValue to update the amount in the account.  This method returns true if withdrawal is made, otherwise false
There is a method calcValue with no parameters which calculates the interest for the month (assume a monthly interest payment so divide rate by 12).
Then add to totalInterestEarned the interest calculated
Call setInvestmentValue which adds the interest the investmentValue (so that interest is collected on the entire amount).
There is a toString method that uses super.toString to help print out the SavingsAccount data (for the appropriate subclass in accord with the portfolioresults.txt file (found in the homework).

CheckingAccount (20)
A CheckingAccount is a subclass of a BankAccount with a minimum balance for free checking, and an annual interest rate (paid monthly) on all the money if the minimum balance is met, and a charge per check if the minimum balance isnt met.
CheckingAccount includes type double instance variables annualInterestRatePercentage, rate, totalInterestEarned, minimumCheckFreeBalance, checkCharge and totalCheckCharges, as well as the inherited instance variables. Each of annualInterestRatePercentage,  totalInterestEarned, minimumCheckFreeBalance, checkCharge and totalCheckCharges have accessors and mutators. The setAnnualInterestRatePercent method also calculates the associated rate of return (divide 100.0)
There is a default constructor that calls the super default constructor.
There is a constructor with name and accountNumber, and the  initialDeposit, annualInterestRatePercentage, minimumCheckFreeBalance and checkCharge.
Call super with “CheckingAccount”, bankName, accountNumber.
Call setInvestmentValue to the initialDeposit.
Call setMinimumCheckFreeBalance.
Call setCheckCharge.
There is a method makeDeposit with a double deposit input parameter that uses setInvestmentValue to update the amount in the account.
There is a method writeCheck with a double checkValue
If there is not enough in the account to cover the check, print a message to the terminal indicating insufficient funds and return false.
If the investmentValue >= the minimumCheckFreeBalance
Update the investment value by deducting the check value
          else
        Update the investment value by deducting the check value and the check charge
        Update totalCheckCharges
          Return true
There is a method calcValue with no parameters (we are assuming a monthly update)
If the investmentValue >= minimumCheckFreeBalance
Calculate this months interest based on a monthly rate (divide rate by 12).
Adds interest to the totalInterestEarned
Updates the investmentValue
There is a toString method that uses super.toString to help print out the SavingsAccount data (for the appropriate subclass in accord with the portfolioresults.txt file (found in the homework).

Portfolio (60)
There is a class Portfolio that has three purposes, initializing, managing and reporting on the portfolio. You will need to import a number of classes, and use throws IOException in several headers.  You dont need to implement try and catch unless you wish to.
The instance variables are
private String portfolioName;
private ArrayList<Investment> portfolioInvestments = new ArrayList<Investment>();
private Random randy;
public Scanner keyboard = new Scanner(System.in);
There is a default constructor that sets the portfolioName to none
There is a constructor with a portfolio name and a seed.
The constructor sets the portfolio name
The constructor creates Random object using the input seed.
There is a method initializePortfolio with no parameters
Asks for the name of an input file ( see my file portfolio.txt for format to read in the investments.) You can use this file for testing.
Create a Scanner to read from this file
Reads in investments from the file (check to make sure the file exists) ne at a time, first determining the type and then reading in the rest of the values. Create the object and place in portfolioInvestments ArrayList.
When done with the file close the Scanner associated with it.
There is a modelPortfolio method with a single input with the number of months to model.
For each month
    For each investment in the portfolioInvestments ArrayList
        If a Stock
            Every three months (quarterly)
Randomly generate a type double price change of between -10% and +20% (Use global randy)
Randomly generate a type double dividendPercent between 0 and 5% (Use global randy)
Call calcStockValues for this Stock with appropriate parameters
ElseIf a Bond
Call calcBondValues() for this Bond
ElseIf a SavingsAccount
    Do 3 times (3 transactions per month)
Generate a deposit or withdrawal between -$600.00 and $1000.00 (Use global randy)
If deposit (positive number)
Call makeDeposit for this SavingsAccount with appropriate parameter
If withdrawal (positive number)
Call makeWithdrawal for this SavingsAccount with appropriate parameter
Call calcValue for this SavingsAccount
ElseIf a CheckingAccount
Generate a deposit between $500.00 and $1500.00 (Use global randy)
Call makeDeposit for this CheckingAccount with appropriate parameter
    Do 4 times per month (writing 4 checks)
        Generate a check between $10.00 and $300.00 (Use global randy)
Call writeCheck for this CheckingAccount with appropriate parameter
Call calcValue for this SavingsAccount (This done once at end of month to calculate interest, if any)
There is a method called generatePortfolioReport with an int months as a parameter
Ask for the name of an output file
Create a PrintWriter that writes to that file
Note look at my portfolioresults.txt file for a formatting suggestion
Print the header
For each investment
Print out its information using toString
Print out the total value of the portfolio
Close the PrintWriter

TestPortfolioManager (10)
This class contains the main method.
Create a Scanner to read in data from the terminal

Request and read in the name of the portfolio.
Request and read n a seed.
Create a Portfolio object with the portfolio name and seed.
Call initializePortfolio for the Portfolio object.
Request and read in the number of months to model.
Call modelPortfolio for the Portfolio object with the number of months.
Call generatePortfolioReport for the Portfolio object with the number of months.

Sample interactive part
Please enter the name of the portfolio: Computer Student
Please enter a seed to use to create a Random object in the portfolio: 2
Please enter name of file to read the portfolio from: portfolioinput.txt
Please enter the duration in months to model this portfolio: 60
Please enter name of file to write portfolio results to: portfolioresults.txt