-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram68.java
50 lines (42 loc) · 1.03 KB
/
Program68.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
49
50
/* Program 68
06/08/24 */
import java.util.Scanner;
public class Telephone {
int prv;
int pre;
int call;
String name;
double amt;
double total;
public void input() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter previous reading: ");
prv = sc.nextInt();
System.out.print("Enter present reading: ");
pre = sc.nextInt();
System.out.print("Enter name: ");
name = sc.next();
call = pre - prv;
}
public void cal() {
if (call <= 100) {
amt = 0;
} else if (call <= 200) {
amt = (call - 100) * 0.9;
} else if (call <= 400) {
amt = 100 * 0.9 + (call - 200) * 0.8;
} else {
amt = 100 * 0.9 + 200 * 0.8 + (call - 400) * 0.7;
}
total = amt + 180;
}
public void display() {
System.out.printf("Name of the customer\tCalls Made\tAmount\t\tAmount to be Paid\n%s\t\t\t%d\t\t%f\t%f\n", name, call, amt, total);
}
public static void main(String args[]) {
Telephone t = new Telephone();
t.input();
t.cal();
t.display();
}
}