Page 1 :
Sunday, August 08, 2021, 10:08 AM, , COMBINED ICSE 246 Page 1
Page 3 :
Define a class named BookFair with the following description: [15], 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, Less than or equal to Rs. 1000, More than Rs. 1000 and less than or equal to Rs. 3000, More than % 3000, , Discount, 2% of price, 10% of price, 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., , COMBINED ICSE 246 Page 3
Page 4 :
Design a class name ShowRoom with the following description :, , Instance variables/ Data members :, String name – To store the name of the customer, long mobno – To store the mobile number of the customer, double cost – To store the cost of the items purchased, double dis – To store the discount amount, double amount – To store the amount to be paid after discount, Member methods: –, ShowRoom() – default constructor to initialize data members, void input() – To input customer name, mobile number, cost, void calculate() – To calculate discount on the cost of purchased items, based on following criteria, Cost, Less than or equal to 10000, More than ₹10000 and less than or equal to ₹20000, More than ₹20000 and less than or equal to ₹35000, More than ₹35000, , Discount (in percentage), 5%, 10%, 15%, 20%, , void display() – To display customer name, mobile number, amount to be paid after discount, Write a main method to create an object of the class and call the above member methods., , import java.util.*;, class showroom, {, String name;, long mobno;double cost,dis,amount;, showroom(), {, name="ABC";, mobno=0L;, cost=0.0;, dis=0.0;, amount=0.0;, , COMBINED ICSE 246 Page 4
Page 5 :
}, void input(), {, Scanner sc=new Scanner(System.in);, System.out.println("Enter name, mobile and cost");, name=sc.nextLine();, mobno=sc.nextLong();, cost=sc.nextDouble();, }, void calculate(), {, if(cost<=10000), dis=5/100.0*cost;, else if(cost>10000 && cost<=20000), dis=10/100.0*cost;, else if(cost>20000 && cost<=35000), dis=15/100.0*cost;, else, dis=20/100.0*cost;, amount=cost-dis;, }, void display(), {, System.out.println("Name="+name);, System.out.println("Mobile Number="+mobno);, System.out.println("Amount="+amount);, }, public static void main(), {, showroom obj=new showroom();, obj.input();, obj.calculate();, obj.display();, }, }, , COMBINED ICSE 246 Page 5