0% found this document useful (0 votes)
71 views3 pages

Book Fair

Define a class named BookFair with the following description: Instance variables/Data members: String Bname stores the name of the book. double price stores the price of the book. Member Methods: (i) BookFair() Default constructor to initialize data members. (ii) void Input() To input and store the name and the price of the book. (iii) void calculate() To calculate the price after discount. Discount is calculated based on the following criteria. Price Discount Less than or equal to Rs 1000 2% of price More than Rs 1000 and less than or equal to Rs 3000 10% of price More than Rs 3000 15% of price (iv) void display() To display the name and price of the book after discount. Write a main method to create an object of the class and call the above member methods.

Uploaded by

Anuj Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views3 pages

Book Fair

Define a class named BookFair with the following description: Instance variables/Data members: String Bname stores the name of the book. double price stores the price of the book. Member Methods: (i) BookFair() Default constructor to initialize data members. (ii) void Input() To input and store the name and the price of the book. (iii) void calculate() To calculate the price after discount. Discount is calculated based on the following criteria. Price Discount Less than or equal to Rs 1000 2% of price More than Rs 1000 and less than or equal to Rs 3000 10% of price More than Rs 3000 15% of price (iv) void display() To display the name and price of the book after discount. Write a main method to create an object of the class and call the above member methods.

Uploaded by

Anuj Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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