forked from chennakrishnans/JAVA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pnr.java
48 lines (44 loc) · 1.15 KB
/
pnr.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.*;
class pnr
{
public static void main(String[] args)
{
try
{
double p;
int n;
double r,i;
Scanner sc=new Scanner(System.in);
System.out.print("Is the person is senior citizen(y/n): ");
char g=sc.next().charAt(0);
System.out.println("Enter the principal amount:");
p=sc.nextDouble();
System.out.println("Enter the no.of.years:");
n=sc.nextInt();
if(g=='y'||g=='Y')
{
r=12;
i=p*n*r/100;
System.out.println("Interest:"+i);
}
if(g=='n'||g=='N')
{
r=10;
i=p*n*r/100;
System.out.println("Interest:"+i);
}
if(p<=0)
{
System.out.println("Enter the valid amount");
}
if(n<=0)
{
System.out.println("Enter the valid no.of.years");
}
}
catch(Exception e)
{
System.out.println("Enter the amount");
}
}
}