Problem B: Cha-CHING Inc. (20 points) Reuse your code from part A. Find the item
ID: 3573964 • Letter: P
Question
Problem B: Cha-CHING Inc. (20 points) Reuse your code from part A. Find the item with the most profit and make that item. Repeat this process 20 times and show your total profit over the period. However, after making an item, the cost of the materials you buy increases by 10%. If multiple materials are used in a single recipe, each the cost is increased multiple times. For example, making a “Spear” in “items1.txt” takes 2 pieces of “Wood”. Each “Wood” initially costs 2.5. Buying the first piece of wood increases this from 2.5 to 2.75 and the second increases it from 2.75 to 3.025. This price increase is applied after you buy the wood. So your the first “Spear” made has a wood cost of 2 x 2.5 = 5, while the second “Spear” has a wood cost of 2 x 3.025 = 6.05.
If no items make profit, simply make the first item on the list.
Example 1 (user input is underlined):
What file to load?
items1.txt Time 1: Making Spear, total profit = 40.2
Time 2: Making Spear, total profit = 78.8
Time 3: Making Spear, total profit = 115.525
Time 4: Making Spear, total profit = 150.046
Time 5: Making Spear, total profit = 181.976
Time 6: Making Spear, total profit = 210.849
Time 7: Making Spear, total profit = 236.113
Time 8: Making Spear, total profit = 257.108
Time 9: Making Spear, total profit = 273.043
Time 10: Making Spear, total profit = 282.975
Time 11: Making Spear, total profit = 285.772
Time 12: Making Wood, total profit = 285.772
Time 13: Making Wood, total profit = 285.772
Time 14: Making Wood, total profit = 285.772
Time 15: Making Wood, total profit = 285.772
Time 16: Making Wood, total profit = 285.772
Time 17: Making Wood, total profit = 285.772
Time 18: Making Wood, total profit = 285.772
Time 19: Making Wood, total profit = 285.772
Time 20: Making Wood, total profit = 285.772
Example 2 (user input is underlined): What file to load?
items2.txt
Time 1: Making Scare_Crow, total profit = 100.58
Time 2: Making Scare_Crow, total profit = 199.216
Time 3: Making Scare_Crow, total profit = 295.713
Time 4: Making Scare_Crow, total profit = 389.856
Time 5: Making Scare_Crow, total profit = 481.409
Time 6: Making Scare_Crow, total profit = 570.114
Time 7: Making Scare_Crow, total profit = 655.682
Time 8: Making Scare_Crow, total profit = 737.801
Time 9: Making Scare_Crow, total profit = 816.124
Time 10: Making Scare_Crow, total profit = 890.268
Time 11: Making Scare_Crow, total profit = 959.815
Time 12: Making Scare_Crow, total profit = 1024.3
Time 13: Making Scare_Crow, total profit = 1083.22
Time 14: Making Substitute_Teacher, total profit = 1138.72
Time 15: Making Substitute_Teacher, total profit = 1190.77
Time 16: Making Scare_Crow, total profit = 1240.51
Time 17: Making Cat_Toy, total profit = 1289.79
Time 18: Making Cat_Toy, total profit = 1338.63
Time 19: Making Cat_Toy, total profit = 1386.76
Time 20: Making Cat_Toy, total profit = 1433.75
Explanation / Answer
Here is the answer for your question.
The file to load is items2.txt
So the answer is items2.txt
Because we are asked to load a file which has more profits.
Time 1: Making Scare_Crow, total profit = 100.58
Time 2: Making Scare_Crow, total profit = 199.216
Time 3: Making Scare_Crow, total profit = 295.713
Time 4: Making Scare_Crow, total profit = 389.856
Time 5: Making Scare_Crow, total profit = 481.409
Time 6: Making Scare_Crow, total profit = 570.114
Time 7: Making Scare_Crow, total profit = 655.682
Time 8: Making Scare_Crow, total profit = 737.801
Time 9: Making Scare_Crow, total profit = 816.124
Time 10: Making Scare_Crow, total profit = 890.268
Time 11: Making Scare_Crow, total profit = 959.815
Time 12: Making Scare_Crow, total profit = 1024.3
Time 13: Making Scare_Crow, total profit = 1083.22
Time 14: Making Substitute_Teacher, total profit = 1138.72
Time 15: Making Substitute_Teacher, total profit = 1190.77
Time 16: Making Scare_Crow, total profit = 1240.51
Time 17: Making Cat_Toy, total profit = 1289.79
Time 18: Making Cat_Toy, total profit = 1338.63
Time 19: Making Cat_Toy, total profit = 1386.76
Time 20: Making Cat_Toy, total profit = 1433.75
It has been given If no items make profit, simply make the first item on the list.
Taking this into consideration we can view the times.
In first case i.e. items1.txt from time 10 onwards there are no profits.
Where as in the second case there are more profits because the times are not repeated.
So the answer is items2.txt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.