-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBillConstructors.java
More file actions
65 lines (57 loc) · 1.09 KB
/
BillConstructors.java
File metadata and controls
65 lines (57 loc) · 1.09 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package practical;
import java.util.Scanner;
import java.io.*;
class Telcall{
String phno;
String sname;
int n;
double amt=0;
Telcall(String phno,String sname,int n)
{
this.phno=phno;
this.sname=sname;
this.n=n;
}
void Compute()
{
if(1<n && n<=100)
{
amt=500;
}
else if(100<n && n<=200)
{
amt=1.0*(n-100)+500;
}
else if(200<n && n<=300)
{
amt=(n-200)*1.20+100+500;
}
else
{
amt=(n-300)*1.50+120+100+500;
}
}
void display()
{
System.out.println("Subscriber Name : " +sname);
System.out.println("Phone number : " +phno);
System.out.println("Number of Calls Made : " +n);
System.out.println("Bill Amount : " +amt);
}
}
public class Test{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter phone number : ");
String phno=sc.nextLine();
System.out.print("Enter Subscriber Name : ");
String sname=sc.nextLine();
System.out.print("Enter numbers of Calls made : ");
int n=sc.nextInt();
Telcall T=new Telcall(phno,sname,n);
T.Compute();
T.display();
sc.close();
}
}