Write a Java program code: Scenario: One of the renowned supermarket in Dhaka City, “Shwapno” is celebrating their first anniversary of opening. They have become very popular among people in a short amount of time. As a method of celebration they have designed three interesting and exciting offer for their customers for that day only!! The offers are described as follows: Offer 1: This offer says, if the name of any customer starts with “S” OR ends with “o”, they will receive a gift which contains 1 kg miniket rice and 1 litre soyabean oil. This offer is dedicated from their name, Shwapno. Offer 2: This offer says, if one customer have taken products and his/her total product weight is less than 1.50 kg, then Shwapno will give all the products to the customer for free. If the total weight is 1.50 kg or more, the customer will have to pay the full amount. Offer 3: This offer says, if a customer is aged less than 15, then he/she will receive chocolates. If aged 15 or more, then no gifts for the customer. Implementation: Create three custom exception classes which represents each offer given above. You may give any names you like to the custom exception classes. Create a class named, Shwapno, containing three methods checkName(), checkproductWeight() and checkAge(), which will throw the custom exceptions you created. In the main, create an object of class Shwapno. Now take name, age and product weight from the user, and call the methods of that in try block followed by a catch block. Output must contain: Exception output Normal output
Write a Java program code:
Scenario:
One of the renowned supermarket in Dhaka City, “Shwapno” is celebrating their first
anniversary of opening. They have become very popular among people in a short amount of
time. As a method of celebration they have designed three interesting and exciting offer for their
customers for that day only!! The offers are described as follows:
Offer 1: This offer says, if the name of any customer starts with “S” OR ends with “o”, they
will receive a gift which contains 1 kg miniket rice and 1 litre soyabean oil. This offer is
dedicated from their name, Shwapno.
Offer 2: This offer says, if one customer have taken products and his/her total product weight
is less than 1.50 kg, then Shwapno will give all the products to the customer for free. If the total
weight is 1.50 kg or more, the customer will have to pay the full amount.
Offer 3: This offer says, if a customer is aged less than 15, then he/she will receive chocolates.
If aged 15 or more, then no gifts for the customer.
Implementation:
Create three custom exception classes which represents each offer given above. You may give
any names you like to the custom exception classes.
Create a class named, Shwapno, containing three methods checkName(), checkproductWeight()
and checkAge(), which will throw the custom exceptions you created.
In the main, create an object of class Shwapno. Now take name, age and product weight from the
user, and call the methods of that in try block followed by a catch block.
Output must contain:
Exception output
Normal output
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images