-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathBookFair.java
More file actions
52 lines (47 loc) · 964 Bytes
/
BookFair.java
File metadata and controls
52 lines (47 loc) · 964 Bytes
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
import java.io.*;
class BookFair
{
String bname;
double price;
public BookFair()
{
bname=" ";
price=0.00;
}
public void input()throws IOException
{
BufferedReader y = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input book name");
bname=y.readLine();
System.out.println("Input price");
price=Integer.parseInt(y.readLine());
}
public void calculate()
{
if(price<=1000)
{
price=price-price*0.02;
}
else if((price>1000)&&(price<=3000))
{
price=price-price*0.1;
}
else
{
price=price-price*0.15;
}
}
public void display()
{
System.out.println(" "+bname+" - "+price);
}
public static void main(String args[])throws IOException
{
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader y = new BufferedReader(in);
BookFair obj= new BookFair();
obj.input();
obj.calculate();
obj.display();
}
}