Class Objectsassignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Class Object Based Assignment

1) Design a class BookFair with the following description:


Instance variables:
String bookname,authorName,float price
Instance methods:
void setBookDetails(String bookname,String authorname,float price) :to store the details of
the book
void calculateDiscount():to calculate the discount based on the following criteria.
Price discount
Less than or equal to 1000 2%of the price
More than 1000 and less than or 10% of the price
Equal to 3000
More than 3000 15% of the price
void display():to display the bookname, author and price after discount.
Create main method to take user input using Scanner class for BookFair variables .Create
object of BookFair class and invoke/call the instance methods
2) Design a class Movie with the following description:
Instance variables :
float rating, String movieName
Instance Methods:
void setDetails(float rating,String name):To set the movie name and rating
void display():To display name and rating with a message using following table.
Rating Message Displayed
0.0 to 2.0 Flop
2.1 to 3.4 Semi-Hit
3.5 to 4.5 Hit
4.5 to 5.0 Super Hit.
Create main method to take user input using Scanner class for movie name and rating Create
object of Movie class and invoke/call the instance methods.

You might also like