import java.util.*;
class p4{
Scanner sc=new Scanner(System.in);
String bname;
double price;
double discount;
p4(){
discount=0.0;
bname=””;
price=0.0;
}
void input(){
System.out.println(“Enter name of the book”);
bname=sc.nextLine();
System.out.println(“Enter price of the book”);
price=sc.nextDouble();
}
void calculate(){
if(price<=1000)
discount=price*0.02;
else if(price>1000 && price<=3000)
discount=price*0.1;
else if(price>3000)
discount=price*0.15;
}
void display(){
System.out.println(“Name of the book=”+bname);
System.out.println(“Price of the book after discount=”+(price-discount));
}
public static void main(){
p4 obj=new p4();
obj.input();
obj.calculate();
obj.display();
}
}