forked from pikachu-17/java-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq1w2.java
More file actions
57 lines (50 loc) · 1.25 KB
/
q1w2.java
File metadata and controls
57 lines (50 loc) · 1.25 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
import java.util.*;
public class electricity
{
int customer_id;
String name;
int units;
double bill;
double scharge;
public electricity()
{
customer_id=0;
name="";
units=0;
bill=0.0d;
}
public void input()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter your customer id");
customer_id=sc.nextInt();
System.out.println("Enter your name");
name=sc.next();
System.out.println("Enter no of units consumed");
units=sc.nextInt();
}
public void calculate()
{
if(units<=100)
bill=3*units;
else if(units>=100 && units<=200)
bill=300+(units-100)*5;
else if(units>=200 && units<=300)
bill=300+500+(units-200)*7;
else if(units>300)
bill=300+500+700+(units-300)*10;
scharge=bill*0.05;
bill=scharge+bill;
}
public void display()
{
System.out.println("Customer ID"+customer_id+"name"+name+"units"+units+"Bill amount"+bill);
}
public static void main()
{
electricity obj=new electricity();
obj.input();
obj.calculate();
obj.display();
}
}