Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m seeing this assignment post for 1 investor, I\'m having issues creating it

ID: 3774386 • Letter: I

Question

I'm seeing this assignment post for 1 investor, I'm having issues creating it for 2 investors (two accounts). Help Please!

Directions
Points
The files must be called <LiFiUnit4Ch13.java> The files must be called <LiFiUnit4Ch13Inevstor.java> (LiFi = Last Initial First Initial)
Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.
Only submit the .java files needed to make the program run. Do not submit the .class files or any other files.
5%
Style Components
Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.
5%
Topics covered in chapter
Topics with * are covered in this assignment. Ensure you use every item listed below in your completed assignment.
*Composition and Aggregation
*Inheritance
*Constructors in a Subclass
Method Overriding
*Final Access Modifier
Basic Requirements
Write a program that tracks an investments for 2 person based on the input of an interest rate. The initial balance should be $2,000, and $4,000. The interest should be added to the balance and output in table format as shown in the supplied sample.
LiFiUnit4Ch13.java
o Instantiate an investor1 object using a two parameter constructor passing the account number 1001 and the initial balance of $2,000
o Instantiate an investor2 object using a two parameter constructor passing the account number 2001 and the initial balance of $4,000
o Get input for interest rate (in the format .08 for 8%)
45%
Use class variable to set interest rate
o Output header as per sample showing interest rate
o Print the table using a for loop displaying the current month and calling:
addInterest() to add the monthly interest for each iteration
getBalance() to display the current balance (See sample)
Output results for 15 months.
o Print the interest earned as shown in the sample for each investor utilizing a printf statement. Don’t hard code the interest earned, or interest rate.
Sample output is provided below. Be sure to mimic it exactly except for values will change based on the interest rate entered.
LiFiUnit4Ch13Investor.java
o All variables should be declared private.
o Declare a class variable called interestRate (This will hold the annual interest rate)
o Declare a constant called ACCOUNT_NUMBER
o Declare an instance variable called balance
o Provide a class method that will be used to set the annual interest rate
o Provide a two parameter constructor to initialize the constant account number and balance
o Provide an addInterest() method to update the balance based on the interestRate entered in the driver.
Add the interest using (balance * interestRate / 12)
45%
NOTE: Complete your activity and submit it by clicking “Submit Assignment”
Total Percentage
100%
Sample Your output will vary based on interest rate entered

Explanation / Answer

//put all three class in separte notepad

//run class three having main method as java 0.08 1001

//java 0.08 1002

//class 1

package com.finance;

public abstract class Finance {
  
       private double interestRate;
      
       public double getInterestRate() {
           return interestRate;
       }
       public void setInterestRate(double interestRate) {
           this.interestRate = interestRate;
       }
      
      
       public abstract double calculateInterest(double interestRate, double tenure,double balance);

}

//class 2

package com.finance;

public class LiFiUnit4Ch13Inevstor extends Finance{
   private String name;
   private int uniqueId;
   private int accountNumber;
   private int initialBalance;
  
   public LiFiUnit4Ch13Inevstor(int accountNumber, int initialBalance)
   {
       this.accountNumber=accountNumber;
       this.initialBalance=initialBalance;
   }

   public double calculateInterest(double interestRate, double tenure, double balance) {
       //SI=(PRT)/100
       //System.out.println("interestRate:"+interestRate+" tenure:"+tenure+" balance:"+balance);
       return ((balance)*(interestRate)*tenure);
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public int getUniqueId() {
       return uniqueId;
   }

   public void setUniqueId(int uniqueId) {
       this.uniqueId = uniqueId;
   }

   public int getAccountNumber() {
       return accountNumber;
   }

   public void setAccountNumber(int accountNumber) {
       this.accountNumber = accountNumber;
   }

   public int getInitialBalance() {
       return initialBalance;
   }

   public void setInitialBalance(int initialBalance) {
       this.initialBalance = initialBalance;
   }
  
  
}

//class 3, class having main method

package com.finance;

public class LiFiUnit4Ch13 {
  
   public static void main(String[] args) {
       LiFiUnit4Ch13Inevstor investor;
       String rate=args[0];
       System.out.println("Interest Rate per month is:"+rate);
       String accountNo=args[1];
       System.out.print("For AccountNumber : "+accountNo);
  
       double rateUnit=Double.parseDouble(rate);
       double simpleInterest=0;
       double initialBalance;
      
       switch(accountNo)
       {
       case "1001":
           investor=new LiFiUnit4Ch13Inevstor(1001, 2000);
           initialBalance=2000;
           for(int t=1;t<13;t++){
           System.out.println("Pricipal :"+initialBalance);
           simpleInterest=(investor.calculateInterest(rateUnit,t,2000))/1200;
           initialBalance=initialBalance+simpleInterest;
           System.out.println("For account 1001, simpleInterest for month : "+t+" = "+simpleInterest+" ");
          
           }
           break;
       case "1002":
           investor=new LiFiUnit4Ch13Inevstor(1002, 4000);
           initialBalance=4000;
           for(int t=1;t<13;t++){
               simpleInterest=investor.calculateInterest(rateUnit, t ,initialBalance);
               System.out.println("For account 1002, simpleInterest for month : "+t+" = "+simpleInterest);
               }
           break;
       default:
           System.out.println("No account Matched with ID:"+accountNo);
       }
      
       //LiFiUnit4Ch13Inevstor investor=new LiFiUnit4Ch13Inevstor();
       LiFiUnit4Ch13 cal=new LiFiUnit4Ch13();
      

   }
  
  

}

//---------------------output--

/*

Interest Rate per month is:0.08
For AccountNumber : 10011001
Pricipal :2000.0
For account 1001, simpleInterest for month : 1 = 0.13333333333333333


Pricipal :2000.1333333333334
For account 1001, simpleInterest for month : 2 = 0.26666666666666666


Pricipal :2000.4
For account 1001, simpleInterest for month : 3 = 0.4


Pricipal :2000.8000000000002
For account 1001, simpleInterest for month : 4 = 0.5333333333333333


Pricipal :2001.3333333333335
For account 1001, simpleInterest for month : 5 = 0.6666666666666666


Pricipal :2002.0000000000002
For account 1001, simpleInterest for month : 6 = 0.8


Pricipal :2002.8000000000002
For account 1001, simpleInterest for month : 7 = 0.9333333333333333


Pricipal :2003.7333333333336
For account 1001, simpleInterest for month : 8 = 1.0666666666666667


Pricipal :2004.8000000000002
For account 1001, simpleInterest for month : 9 = 1.2


Pricipal :2006.0000000000002
For account 1001, simpleInterest for month : 10 = 1.3333333333333333


Pricipal :2007.3333333333335
For account 1001, simpleInterest for month : 11 = 1.4666666666666666


Pricipal :2008.8000000000002
For account 1001, simpleInterest for month : 12 = 1.6

*/