Computer Science, asked by akathesom1, 3 months ago

LeeLee mall provides a discount coupon to their customer. The customer can use this coupon to buy the products, so that they can avail a discount for the product they bought. The coupon provided by the mall is not applicable for all the products. The customer can use the coupon to avail discount for a certain category of products. The table given below list outs the category and its percentage of discount of several category of products.

Category

Discount percentage

Electronic

10%

Furniture

5%

Cosmetics

2%

The discount is applicable only for the above categories.
In the Product and category class includes the given attributes and methods with the access specifiers as specified in the class diagram.

The setter methods are used to set the value and the getter methods are used to retrieve the value.

The applyCoupon method should check whether the coupon is applicable for that category, if applicable, apply the discount to that product and reduce the discount amount from the product price and set the new price. If the coupon is not applicable, then there is no discount and the original price remains same.

In the Main class, create an object for the Product and category class; Get the details as shown in the sample input and assign the value for its attributes using the setters. Invoke the applyCoupon method and display the details as shown in the sample output using the getters method.

Sample Input1:

Enter the product id:

123

Enter the product name:

tv

Enter the price:

50000

Enter the category id:

202

Enter the category name:

Electronic

Sample Output1:

You need to pay 45000.00 for the Electronic - tv

Sample Input2:

Enter the product id:

124

Enter the product name:

shirt

Enter the price:

5000

Enter the category id:

203

Enter the category name:

Apparels

Sample Output2:

You need to pay 5000.00 for the Apparels - shirt

Answers

Answered by chandrasekhar42
0

Answer:

LeeLee mall provides a discount coupon to their customer. The customer can use this coupon to buy the products, so that they can avail a discount for the product they bought. The coupon provided by the mall is not applicable for all the products. The customer can use the coupon to avail discount for a certain category of products. The table given below list outs the category and its percentage of discount of several category of products.

Category

Discount percentage

Electronic

10%

Furniture

5%

Cosmetics

2%

The discount is applicable only for the above categories.

In the Product and category class includes the given attributes and methods with the access specifiers as specified in the class diagram.

The setter methods are used to set the value and the getter methods are used to retrieve the value.

The applyCoupon method should check whether the coupon is applicable for that category, if applicable, apply the discount to that product and reduce the discount amount from the product price and set the new price. If the coupon is not applicable, then there is no discount and the original price remains same.

In the Main class, create an object for the Product and category class; Get the details as shown in the sample input and assign the value for its attributes using the setters. Invoke the applyCoupon method and display the details as shown in the sample output using the getters method.

Sample Input1:

Enter the product id:

123

Enter the product name:

tv

Enter the price:

50000

Enter the category id:

202

Enter the category name:

Electronic

Sample Output1:

You need to pay 45000.00 for the Electronic - tv

Sample Input2:

Enter the product id:

124

Enter the product name:

shirt

Enter the price:

5000

Enter the category id:

203

Enter the category name:

Similar questions