HELLO DORAEMONS,
Write the code to define a class to create objects of type Toy with following attributes:
Toy ID
Toy Type:
Price.
Discount Applicable Define a method in the class which sets values to the first 3 attributes by taking values as argument in the sequence mentioned above while creating a Toy object
Value for Discount Applicable should be set to 0
Write the code to define a Class to create a Store object with following attributes:
A list of Toy Objects Applicable Discount Details for different Toy Types are stored as key value pairs as "Toy Type: discount
Define a method in the class which sets values to the attributes by taking values as argument in the sequence mentioned above while creating a Store object.
Define another method inside the class to fulfil the requirements defined below:
This method will be used to calculate the discount for the Toys in the Toy list of the Store
For each Toy in the Toy List of the Organization, method will calculate the discount amount based on the Toy Type and the discount rate for that Toy Type maintained by the store. Method will update the value of the discount applicable attribute of the Toy with the value (discount amount calculated using the following formula:
Discount Applicable - price + (discount rate/100).
If the Toy Type of Toy is not found in the discount 26 details of the store as key for any key value pairs, discount applicable is considered as 0.
This method will not return any value.
For more clarity, please refer to the sample input and output below.
Note: All the searches should be case insensitive. Instructions to write main section of the code
Instructions to write main section of the code:
You would require to write the main section completely, hence please follow the below instructions for the same.
Note: You need to press "Final Submit" for your program to be considered for
Auto-closed due 1. All the comparisons are case insensitive.
2. In the test case input Boolean value is given as
Program E "true" or "false" (although small letter) however in the output it is printed as "True" or "False". (No need to do anything it will be automatically printed as "True" or "false")
Instructions to write main section of a code.
1. You would require write the main section Completely, hence please follow the below instructions for the same
2. You would require writing main program which is in line to the "Sample input description" section and to read the data in the same sequence as mentioned below
3. Create an object as manager for Toy Store class
4 create an object of Toy after reading the attribute data related to it with the given sequence of arguments to fulfil the constructor requirements
5. Print the Toy id, Price and the Price after discount for each Toy in the Toy List of the Store one by one (with a single space between each value)
In the output the details of the toy with highest discount amount should be in the top of the list i.e. in the descending order of "Price after discount")
Refer to sample output for more details on format of the output Sample Input (below) description:
1. The first input to be given is the count of Toy objects to be created and added to the Toy list of the Store class.
2. The next set of inputs are the Toy ld, Toy Type and Price of the for each Toy object taken one after another and is repeated for the number of Toy objects given in the point#1
3. The next input refers the values for 3 "Toy Type: discount rate" pair for the list for Applicable Discount Details or different Toy Types of the Store.
Sample Input:
4
101
Puzzle
550
102
Light and sound
700
103
Puzzle
600
104
Soft Toy
1500
Soft Toy
12
Puzzle
15
Electronics
10
Output:
104 1500 1320.0
103 600 510.0
101 550 467.5
102 700 700
HOPE THIS BLOG IS HELPFUL, FOLLOW MY BLOG FOR MORE SIMILAR QUESTION. IF YOU HAVE ANY DOUBTS , FEEL FREE TO COMMENT IT DOWN.
0 Comentarios