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

Simple interest can be calculated as follows: Interest = P*r*t where P = the pri

ID: 3673116 • Letter: S

Question

Simple interest can be calculated as follows: Interest = P*r*t where P = the principle, r = the interest rate, and t = time in years For example, if a person starts with a principle = $100.00 at an interest rate = 0.04 where time = 3 years. The amount of interest is 12 dollars or 100.0 * 0.04 * 3 = 12 Design a class called Interest whose constructor accepts three arguments. The principle (in dollars), the rate (in decimal format), and the number of years represented as a variable called time (an integer). Besides the appropriate gets (accessors) and sets (mutators), it should have a method named getInterest that returns the interest, in dollars that the investment has earned. Demonstrate the class in a program that uses a while loop (period < = time) to display the interest earned for each year of a time specified by the user. For example, if principle is $100.00, the interest rate is 0.04 for a three-year time period, it should display a report similar to the one shown here. Year Interest Earned 14 28 3 12 Input Validation: Do not accept a negative number for principle and rate, and do not accept any value less than one for time traveled (use while loops to test for principle > = 0, and rate > = 0, and another while loop to test for time > 1). Simple interest can be calculated as follows: Interest = P*r*t where P = the principle, r = the interest rate, and t = time in years For example, if a person starts with a principle = $100.00 at an interest rate = 0.04 where time = 3 years. The amount of interest is 12 dollars or 100.0 * 0.04 * 3 = 12 Design a class called Interest whose constructor accepts three arguments. The principle (in dollars), the rate (in decimal format), and the number of years represented as a variable called time (an integer). Besides the appropriate gets (accessors) and sets (mutators), it should have a method named getInterest that returns the interest, in dollars that the investment has earned. Demonstrate the class in a program that uses a while loop (period < = time) to display the interest earned for each year of a time specified by the user. For example, if principle is $100.00, the interest rate is 0.04 for a three-year time period, it should display a report similar to the one shown here. Year Interest Earned 14 28 3 12 Input Validation: Do not accept a negative number for principle and rate, and do not accept any value less than one for time traveled (use while loops to test for principle > = 0, and rate > = 0, and another while loop to test for time > 1). Simple interest can be calculated as follows: Interest = P*r*t where P = the principle, r = the interest rate, and t = time in years For example, if a person starts with a principle = $100.00 at an interest rate = 0.04 where time = 3 years. The amount of interest is 12 dollars or 100.0 * 0.04 * 3 = 12 Design a class called Interest whose constructor accepts three arguments. The principle (in dollars), the rate (in decimal format), and the number of years represented as a variable called time (an integer). Besides the appropriate gets (accessors) and sets (mutators), it should have a method named getInterest that returns the interest, in dollars that the investment has earned. Demonstrate the class in a program that uses a while loop (period < = time) to display the interest earned for each year of a time specified by the user. For example, if principle is $100.00, the interest rate is 0.04 for a three-year time period, it should display a report similar to the one shown here. Year Interest Earned 14 28 3 12 Input Validation: Do not accept a negative number for principle and rate, and do not accept any value less than one for time traveled (use while loops to test for principle > = 0, and rate > = 0, and another while loop to test for time > 1).

Explanation / Answer

package com.he.capillary;

import java.util.Scanner;

public class Interests {

   private float rate;
   private double principle;
   private Integer year;

   public float getRate() {
       return rate;
   }

   public void setRate(float rate) {
       this.rate = rate;
   }

   public double getPrinciple() {
       return principle;
   }

   public void setPrinciple(double principle) {
       this.principle = principle;
   }

   public Integer getYear() {
       return year;
   }

   public void setYear(Integer year) {
       this.year = year;
   }
  
   public double getInterest(){
       return rate*principle*year*1.0d;
   }

   public Interests(float rate, double principle, Integer year) {
       super();
       this.rate = rate;
       this.principle = principle;
       this.year = year;
   }

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       double principle = 0d;
       float rate = 0f;
       Integer year = 0;
       while(true){
           System.out.println("Please enter Principle : ");
           principle = sc.nextDouble();
           System.out.println("Please enter rate : ");
           rate = sc.nextFloat();
           System.out.println("Please enter time : ");
           year = sc.nextInt();
           if(principle >= 0 && rate >= 0 && year > 1){
               break;
           }else{
               continue;
           }
       }
       Interests interests = new Interests(rate, principle, year);
       int period = 1;
       while(period <= year){
           System.out.println(Math.ceil(rate*principle*year*1.0d));
           period++;
       }
      
   }
}

I didnt get year wise interest because it is simple interest so interest should be same for all years.

Let me know in case of issues.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote