constructors
constructors
Member methods:
Write a main method to create an object of the class and call the above member
methods.
2. Define a class named FruitJuice with the following description:
Member
Purpose
Methods
to input and store the product code, flavour, pack type, pack size and
void input()
product price
to display the product code, flavour, pack type, pack size and product
void display()
price
Write a main method to create an object of the class and call the above member methods.
1
3.Define a class named movieMagic with the following description:
Member
Purpose
Methods
Ratings Table
Write a main method to create an object of the class and call the above member methods.
2
4. Define a class called ParkingLot with the following description:
Member Methods:
Write a main() method to create an object of the class and call the above methods.
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
More than ₹1000 and less than or equal to ₹3000 10% 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.
3
6. Define a class ElectricBill with the following specifications:
class : ElectricBill
Member methods:
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
Write a main method to create an object of the class and call the above member methods.
Member methods:
4
Type of Coaches Amount
First_AC 700
Second_AC 500
Third_AC 250
sleeper None
void display() — To display all details of a customer such as name, coach, total amount
and mobile number.
Write a main method to create an object of the class and call the above member
methods.
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
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.
5
9. Design a class with the following specifications:
Member variables:
name — name of student
age — age of student
mks — marks obtained
stream — stream allocated
Member methods:
mks stream
4.void print() – Display student name, age, mks and stream allocated.
Write a main method to create an object of the class and call the above member methods.
Member variables:
String name: name of the item purchased
double price: Price of the item purchased
Member methods:
6
Price Discount
void display(): To display the name of the item and the net amount to be paid.
Write the main method to create an object and call the above methods.
11. Create a class named Pizza that stores details about a pizza. It should contain the following:
Instance Variables:
String pizzaSize — to store the size of the pizza (small, medium, or large)
int cheese — the number of cheese toppings
int pepperoni — the number of pepperoni toppings
int mushroom — the number of mushroom toppings
Member Methods:
Pizza() — default constructors to initialise all the instance variables
CalculateCost() — A public method that returns a double value, that is, the cost of the pizza.
Pizza cost is calculated as follows:
void print() — display pizza size, quantity of each topping, and the pizza cost as calculated by
CalculateCost().
Write the main method to create an object and call the above methods.
7
12. Define a class Laptop described as follows:
Member Methods:
2. void accept()-To accept the details (name of the customer and the price)
An electronics shop has announced a special discount on the purchase of Laptops as given
below:
Category Discount on Laptop
Up to ₹25,000 5.0%
₹25,001 - ₹50,000 7.5%
₹50,001 - ₹1,00,000 10.0%
More than ₹1,00,000 15.0%
4. void display()-To display the name, discount and amount to be paid after discount.
Write a main method to create an object of the class and call the member methods.
Member methods:
Write a main method to create an object of the class and call the above member methods.