A bank is offering different rate of interest on fixed deposits based on the duration of investment as follows:
TIME Rate p.a.
Up to 1 year 5%
>1 year up to 3 years 5.5%
>3 years 5.25%
Write a program to assign the principal amount and time if duration (in years) and display the
final amount the bank will pay to the customer. A = P(1+R/100)T
Answers
import java.util.*;
public class C_I
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Please Enter The Principle Amount");
double P = sc.nextDouble();
System.out.println("Please Enter The Time Span");
System.out.println(" 1 Year , >1 Year and <= 3 year , >3 year ");
double T = sc.nextDouble();
System.out.println();
if ( T == 1 )
{
double R = 5 ;
double A = P * (Math.pow((1 + (R/100)) , T));
double CI = A - P ;
double V = P + CI ;
System.out.println("Compound Interest on "+P+" At Rate "+R+" And Time "+T+" = "+CI);
System.out.println("Total = "+V);
}
else if ( T > 1 && T <= 3 )
{
double R = 5.5 ;
double A = P * (Math.pow((1 + (R/100)) , T));
double CI = A - P ;
double V = P + CI ;
System.out.println("Compound Interest on "+P+" At Rate "+R+" And Time "+T+" = "+CI);
System.out.println("Total = "+V);
}
else if ( T > 3 )
{
double R = 5.25 ;
double A = P * (Math.pow((1 + (R/100)) , T));
double CI = A - P ;
double V = P + CI ;
System.out.println("Compound Interest on "+P+" At Rate "+R+" And Time "+T+" = "+CI);
System.out.println("Total = "+V);
}
else
{
System.out.println("Invalid");
}
sc.close();
}
}
Answer:
PLEASE convert this in assignment statement