You are on page 1of 3

import java.io.

*;

class BookFair

String Bname;

double price;

BookFair()

Bname="";

price =0.0d;

void input()throws IOException

DataInputStream ak = new DataInputStream(System.in);

System.out.println("Enter Name " );

Bname=ak.readLine();

System.out.println("Enter the price");


price=Integer.parseInt(ak.readLine());

void calculate()

double op1=price;

if(price<=1000)

price= price-price*2/100;

else if(price<=3000)

price =price-price*10/100;

else

price =price-price*15/100;

BookFair obj=new BookFair();

obj.display(price ,Bname,op1 );

public void display(double p1,String Bn1,double op1)

{
System.out.println("Name : \t Original Price Discounted Price" );

System.out.println(Bn1+"\t"+ op1 +"\t"+ p1);

public static void main(String args[])throws IOException

BookFair obj=new BookFair();

obj.input();

obj. calculate();

You might also like