lease show step by step with comments. Please show it in simplest form. Please don't use any functions Please don't use any def func () Input and Output must match with the Question

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

Must show it in Python:
Please show step by step with comments.
Please show it in simplest form.
Please don't use any functions
Please don't use any def func ()
Input and Output must match with the Question
Please go through the Question very carefully.

 

Sample Input 2:
100
10
3
Sample Output 2:
139
Explanation 2:
In this input, the shop will return 3 new chocolates for every 10 empty
packets. So if you have 100 chocolates in the beginning, you can have more
chocolates through the following steps.
Eat 100 chocolates -> 100 empty packs.
100 empty packets -> 30 new chocolates. (3 for each 10)
Eat 30 chocolates -> 30 empty packs.
30 empty packs -> 9 new chocolates.(3 for each 10)
Eat 9 chocolates -> 9 empty packs.
You can't get any more new chocolates with 9 empty packs since 9 is less
than 10.
Now counting all the chocolates you have eaten. You'll get
(100 + 30 + 9) = 139 chocolates in total. So, the output is 139.
Transcribed Image Text:Sample Input 2: 100 10 3 Sample Output 2: 139 Explanation 2: In this input, the shop will return 3 new chocolates for every 10 empty packets. So if you have 100 chocolates in the beginning, you can have more chocolates through the following steps. Eat 100 chocolates -> 100 empty packs. 100 empty packets -> 30 new chocolates. (3 for each 10) Eat 30 chocolates -> 30 empty packs. 30 empty packs -> 9 new chocolates.(3 for each 10) Eat 9 chocolates -> 9 empty packs. You can't get any more new chocolates with 9 empty packs since 9 is less than 10. Now counting all the chocolates you have eaten. You'll get (100 + 30 + 9) = 139 chocolates in total. So, the output is 139.
Question 1:
You will be given three inputs M, N, and P. The M indicates the number of
chocolates you have. And there is a shop where you can get P new chocolates
if you return N empty chocolate packets.
You need to find the total number of chocolates that you can have and print
it.
Sample Input 1:
100
4
1
Sample Output 1:
133
Explanation 1:
In this input, the shop will return 1 new chocolate for every 4 empty
packets. So if you have 100 chocolates in the beginning, you can have more
chocolates through the following steps.
Eat 100 chocolates -> 100 empty packs.
100 empty packs -> 25 new chocolates.
Eat 25 chocolates -> 25 empty packets.
25 empty packets -> 6 new chocolates and 1 empty packet.
Eat 6 chocolates -> (6 + 1 remaining) = 7 empty packs.
7 empty packets -> 1 new chocolate and 3 empty packets.
Eat 1 chocolate -> (1 + 3 remaining) = 4 empty packs.
4 empty packs -> 1 new chocolate.
Eat 1 chocolate -> 1 empty packet.
No new chocolate can be obtained using only 1 packet.
Now counting all the chocolates you have eaten you'll get
(100 + 25 + 6+ 1+ 1) = 133 chocolates in total. So, the output is 133.
Transcribed Image Text:Question 1: You will be given three inputs M, N, and P. The M indicates the number of chocolates you have. And there is a shop where you can get P new chocolates if you return N empty chocolate packets. You need to find the total number of chocolates that you can have and print it. Sample Input 1: 100 4 1 Sample Output 1: 133 Explanation 1: In this input, the shop will return 1 new chocolate for every 4 empty packets. So if you have 100 chocolates in the beginning, you can have more chocolates through the following steps. Eat 100 chocolates -> 100 empty packs. 100 empty packs -> 25 new chocolates. Eat 25 chocolates -> 25 empty packets. 25 empty packets -> 6 new chocolates and 1 empty packet. Eat 6 chocolates -> (6 + 1 remaining) = 7 empty packs. 7 empty packets -> 1 new chocolate and 3 empty packets. Eat 1 chocolate -> (1 + 3 remaining) = 4 empty packs. 4 empty packs -> 1 new chocolate. Eat 1 chocolate -> 1 empty packet. No new chocolate can be obtained using only 1 packet. Now counting all the chocolates you have eaten you'll get (100 + 25 + 6+ 1+ 1) = 133 chocolates in total. So, the output is 133.
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning