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

Create the logic for a program that calculates and displays the amount of money

ID: 3778897 • Letter: C

Question

Create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed.

Modify the program in 3a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method.

Modify the program in 3b so that the main program also prompts the user for the interest rate and passes both the amount of money and interest rate to the interest-calculating method.

My professor wants our answer to be the final result after each modification. I have the worst professor on the planet so I have resorted to paying for this.I wish I had done it sooner so that I might be able to pass the class, but this is all I've got now.

Explanation / Answer

Since no language is mentioned, I would take liberity to code in most common language JAVA. here is java code for the question:

import java.util.Scanner;

public class SimpleInterest {
   double principal;
   double rate;
   int year;
  
  
  
   public SimpleInterest() {
       this.principal = 5000;
       this.rate = 0.02;
       this.year = 1;
   }
   public double calculateAmount(){
       return principal+principal*rate*year;
   }
   public double calculateAmount(double principal){
       return principal+principal*rate*year;
   }
   public double calculateAmount(double principal,double rate){
       return principal+principal*rate*year;
   }

   public static void main(String[] args) {
       // TODO Auto-generated method stub
       System.out.println("three cases");
       System.out.println("case1 ");
       SimpleInterest si=new SimpleInterest();
       System.out.println(si.calculateAmount());
       Scanner sc=new Scanner(System.in);
       System.out.println("case2");
       System.out.println("Enter principal:");
       double principal=sc.nextDouble();
       System.out.println(si.calculateAmount(principal));
       System.out.println("case3");
       System.out.println("Enter principal:");
       double principal2=sc.nextDouble();
       double rate=sc.nextDouble();
       System.out.println(si.calculateAmount(principal2,rate));
   }

}

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