write a program in java to input amount to deposit and number of years. calculate the interest and total balance amount after the given number is years. print amount deposited amount, number of years, interest earned and total amount paid after the given years.
Answers
/*
Project Type: Brainly Answer
Date Created: 10-02-2021
Date Edited Last Time: ---NIL---
Question Link: https://brainly.in/question/34930519
Question: Write a program in java to input amount to deposit and number of years (and Rate of Interest).
Calculate the interest and total balance amount after the given number is years.
Print amount deposited amount, number of years, interest earned and total amount paid after the given years.
Program Created By: atrs7391
Programming Language: Java
Language version (When program created or last edited): jdk-15.0.2
*/
package Brainly_Answers;
import java.util.Scanner;
public class Simple_Interest_3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the amount to be deposited: ");
double p = sc.nextDouble();
// p means principle, i.e. the amount deposited
System.out.println("Enter the rate of interest per year: ");
double r = sc.nextDouble();
// r means rate of interest
System.out.println("Enter Time in years: ");
double t = sc.nextDouble();
// t means time period
double si = (p*r*t)/100;
// si means simple interest, i.e. the interest earned
double ta = p+si;
// ta means total amount, i.e. the total amount paid
System.out.println("Deposited amount: "+p);
System.out.println("Number of years: "+t);
System.out.println("Interest earned: "+si);
System.out.println("Total amount: "+ta);
// printing deposited amount, number of years,
// interest earned and total amount paid after the given years respectively
}
}