-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ch3_Q5_E_PG_109.java
37 lines (37 loc) · 1.2 KB
/
Ch3_Q5_E_PG_109.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
import java.util.Scanner; //Importing scanner to accept values from user
public class Ch3_Q5_E_PG_109
{
public static void main(String[] args)
{
double D, LF;
Scanner sc = new Scanner(System.in); //Defining scanner
System.out.println(" > Enter the number of days late ");
D = sc.nextDouble(); //Accepting number of days late from user
if(D <= 3) //Using if statement to identify years of service
{
LF = D * 4;
System.out.println(" Late fine is --> " + LF);
}
else if(D > 3 && D <= 7)
{
LF = D * 8;
System.out.println(" Late fine is --> " + LF);
}
else if(D > 7 && D <= 10)
{
LF = D * 12;
System.out.println(" Late fine is --> " + LF);
}
else if(D > 10)
{
LF = D * 15;
System.out.println(" Late fine is --> " + LF);
}
else
{
System.out.println(" > Invalid amount of days late ");
}
sc.close(); //Closing resource leak
System.out.println(" > Contact me on github if you face any issues with the program \n GITHUB ID --> KavinMistry ");
}
}