A bank offers the following rate of interest for fixed deposit: Time(Years) Rate(%) < 1 9.0 1 to 2 10.0 2 to 3 11.0 > 3 12.0 WAP to accept deposited amount(P), number of years(n) the amount is deposited for and compute the accrued amount for an investor.
import java.
util.*;
class Bank
{
public static void main()
{
Scanner Sc=new Scanner(System.in);
System.out.println(“Enter principal amount and the time period”);
double pa=Sc.nextDouble(); int t=Sc.nextInt();
double r=0;
if(t<1)
{ r=9.0;}
else if(t>=1&&t<2)
{ r=10.0;}
else if(t>=2&&t<=3)
{r=11.0;}
else if(t>3)
{ r=12.0;}
double a=p*(Math.pow(t,(1+r/100))); {
System.out.println(“The accrued amount is “+a);
} } }
Output: Enter principal amount and the time period public static void main()
{
Scanner Sc=new Scanner(System.in);
System.out.println(“Enter principal amount and the time period”);
double pa=Sc.nextDouble(); int t=Sc.nextInt();
double r=0;
if(t<1)
{ r=9.0;}
else if(t>=1&&t<2)
{ r=10.0;}
else if(t>=2&&t<=3)
{r=11.0;}
else if(t>3)
{ r=12.0;}
double a=p*(Math.pow(t,(1+r/100))); {
System.out.println(“The accrued amount is “+a);
} } }
1000
2
The accrued amount is 1100
No comments: