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

/* Declare the variables. */ double principal; // The value of the investment. d

ID: 638636 • Letter: #

Question

/* Declare the variables. */

double principal; // The value of the investment.

double rate; // The annual interest rate.

double interest; // Interest earned in one year.

/* Do the computations. */

principal = 17000;

rate = 0.027;

interest = principal * rate; // Compute the interest.

principal = principal + interest;

// Compute value of investment after one year, with interest.

// (Note: The new value replaces the old value of principal.)

/* Output the results. */

System.out.print("The interest earned is $");

System.out.println(interest);

System.out.print("The value of the investment after one year is $");

System.out.println(principal);

} // end of main()

} // end of class Interest

Explanation / Answer

import java.util.Scanner; // the name of our class its public public class SimpleInterest { //void main public static void main (String[] args) { //declare float float a,y,r,si,t; //define scanner Scanner input = new Scanner(System.in); //print message and take input. System.out.println("Enter Amount:"); a = input.nextFloat(); System.out.println("Enter Years"); y = input.nextInt(); System.out.println("Enter Rate of interest"); r = input.nextFloat(); //calculate si=a*y*r/100; t=a+si; //print the output System.out.println("Simple interest = "+si); System.out.println("Total = " + t); } }