Write a program in JAVA. Suppose that the threshold is $1,000, the smaller inter
ID: 3564280 • Letter: W
Question
Write a program in JAVA. Suppose that the threshold is $1,000, the smaller interest rate is 0.9%, the larger interest rate is 1.5%, you invest $990, and you want to trace this amount for 3 years.
Assignment. This is similar to Lab 4, but now, instead of predicting how your deposit will increase in one year, you need to predict how it will increase in a given number of years. Write a program that prompts the user to input: the threshold, the smaller interest rate (in percents), the larger interest rate (in percents), the user's name, the amount the user wants to deposit, and the number of years that the user wants to trace. Your program should find out, for each of these years: what is the effective interest rate for the amount the user deposited, how big is the increase, and what is the resulting amount of money at the end of this year. Example. Suppose that the threshold is $1,000, the smaller interest rate is 0.9%, the larger interest rate is 1.5%, you invest $990, and you want to trace this amount for 3 years. In the first year, the amount is smaller than the threshold, so your effective interest rate is 0.9%. This means that at the end of Year 1, you earn an additional amount of $990 * (0.9 / 100) = $8.91. Thus, at the end of Year 1, your deposit will be equal to $990 + $8.91 = $998.91. The resulting amount is still smaller than the threshold, so in Year 2, your effective interest rate is still 0.9%. This means that at the end of Year 2, you earn an additional amount of $998.91 * (0.9 / 100) = $8.99. Thus, at the end of Year 2, your deposit will be equal to $998.91 + $8.99 = $1,007.90. This amount is already larger than the threshold, so your effective interest rate is 1.5%. This means that at the end of Year 3, you earn an additional amount of $1,007.90 * (1.5 / 100) = $15.12. Thus, at the end of Year 1, your deposit will be equal to $1,007.90 + $15.12 $1,023.02. You should present the results of the computations in a nice and clear form, e.g., as follows: Report on John Johnson's saving account: Original amount 990.00 Year 1: effective interest rate 0.9% amount gained 8.91 amount at the end of Year 998.91 Year 2: effective interest rate 0.9% amount gained 8.99 amount at the end of Year 1007.90 Year 3: effective interest rate 1.5% amount gained 15.12 amount at the end of Year 1023.02 Thanks for using our bank!Explanation / Answer
------------------------------------------------- PROGRAM CLASS INTEREST-------------------------------------------
/**
* @(#)Interest.java
*
*
* @author
* @version 1.00 2014/10/7
*/
import java.util.Scanner;
public class Interest {
public Interest() {
}
public static void main(String args[])
{
double effective_rate;
double amount_gained;
double remain_amount;
//------------------------------INPUT FOR PROGRAM-------------------//
Scanner sc=new Scanner(System.in); // Scanner Class Object for Taking Input
System.out.println("Please Enter Your Name : ");
String user_name=sc.nextLine(); // sc.nextLine method for Taking String Input
System.out.println("Please Enter Threshold Amount : ");
double threshold=sc.nextDouble(); // sc.nextInt method for Double Input
System.out.println("Please Enter Smallest Interest Rate : ");
double smaller_interset_rate=sc.nextDouble();
System.out.println("Please Enter Largest Interest Rate : ");
double largest_interset_rate=sc.nextDouble();
System.out.println("Please Enter Deposited Amount : ");
double amt_deposit=sc.nextDouble();
System.out.println("Please Enter Total Number of Years : ");
int years=sc.nextInt();
//------------------------------------------------------------------//
System.out.println("Report on "+user_name+"'s saving account:");
System.out.println("Original Amount "+amt_deposit+" $ ");
for(int i=1;i<=years;i++)
{
if(amt_deposit<1000)
effective_rate=smaller_interset_rate; // When Amount is more than 1000 then updation in intrest Rate
else
effective_rate=largest_interset_rate;
amount_gained=amt_deposit*effective_rate/100;
remain_amount=amount_gained+amt_deposit;
amt_deposit=remain_amount;
System.out.println(" Year "+i+" : ");
// Formatted Output For Money in 2 point precision after decimal
System.out.println("effective interest rate "+effective_rate+" %");
System.out.printf("ammount gained %.2f$ ",amount_gained);
System.out.printf("amount at the end of Year %.2f$ ",amt_deposit);
}
System.out.println(" Thanks for using our bank !");
}
}
---------------------------------------------OUTPUT --------------------------------------------------------------------
--------------------Configuration: <Default>--------------------
Year1:
Effective interest rate: 0.9
Amount gained: 8.91
Amount at end of the year: 998.91
Year2:
Effective interest rate: 0.9
Amount gained: 8.99
Amount at end of the year: 1007.9
Year3:
Effective interest rate: 1.5
Amount gained: 15.11
Amount at end of the year: 1023.01
Process completed.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.