Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to translate this into code java There is a class Portfolio that has three purposes, initializing, managing and reporting on the portfolio. You

I want to translate this into code java

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 portfolioInvestments = new ArrayList();

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.
    • Create a Scanner to read from this file
    • Reads in investments from the file (check to make sure the file exists) one 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

What is a sales forecast? Why is it important?

Answered: 1 week ago

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is human nature?

Answered: 1 week ago