Question: Question 1 Create a class called Invalid Paramter Erception that extends the java class named Erception. Add a single constructor that accepts a String argument.

 Question 1 Create a class called Invalid Paramter Erception that extendsthe java class named Erception. Add a single constructor that accepts a

Question 1 Create a class called Invalid Paramter Erception that extends the java class named Erception. Add a single constructor that accepts a String argument. The constructor simply calls the parent class (hint: remember what the keyword super does) using the String passed to constructor. Question 2 Create an interface called Investment with the following methods: name: returnValue, arguments: none, returns: double, access: public, throws: InvalidParameterExcep- tion name: returnProfit, arguments: none, returns: double , access: public, throws: InvalidParameterExcep- tion Question 3 a) Create a class called Cash Money that implements Investment with the following fields: name: amount, type: double, access: private name: monthlyInterest, type: double, access: private name: investment Months, type: int, access: private b) Create a default and a parameterized constructor for the CashMney class. The parameterized constructor should accept all 3 fields in the class. c) Populate the approriate methods from the Investment interface. Use the interest rate and number of months of investment investment Months) to calculate the value and profit of the investment. Don't overthink this. Use the following formula to calulate the value of the investment: value = amount x (1 + rate number of periods profit = value - amount d) In your return Value method, determine if either the interest rate or length of investment is negative. If so, throw a custom InvalidParameter Erception with the message below. Note that a try/catch is not required in this method. CashMoney field values are not all valid Question 4 In this question your are asked to consider an investment called Shares. In this context, shares can either represent the shares of a mutual funds that an inidividual owns or the shares of a particular stock that an individual owns. Questions 5 and 6 will ask you to formally expand the notion of stocks and mutual funds. a) Create an abstract class named Shares that implements Investment with the following fields: name: id, type: String, access: public name: sharePrice, type: double, access: public name: sharedPrice, type: double, access: public b) Add a default constructor and a parameterized consructor that initializes all 3 fields in the class. c) Add the necessary abstract methods needed to implement Investment Question 5 Create a class named Stock that extends Shares with the following fields: a) - name: numberShares, type: int, access: public a) Add a default constructor and a parameterized consructor that initializes all fields from the Shares class and the additional field in the Stock class. a) Implement the methods required because we are extending Shares. (Note: the math to implement these methods is very simple) Question 6 Create a class named MFund that extends Shares with the following fields: a) - name: numberShares, type: double, access: public a) Add a default constructor and a parameterized consructor that initializes all fields from the Shares class and the additional field in the Stock class. a) Implement the methods required because we are extending Shares. (Note, again: the math to implement these methods is very simple) Question 7 Create a class called Investment Tester that does the following: a) Creates CashMoney, MFund and Stock objects with values initialized to your choosing. b) Adds the three objects to an ArrayList named Portfolio (you should determine the correct type of the ArrayList). c) Gets the profit associated with the CashMoney investement and prints it to screen with an appropriate label. Uses a try/catch to catch an InvalidParameterException if the interest rate or length of investment associated with your CashMoney are not valid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!