A pastry cook is preparing special dishes for her daughter's birthday. It takes her a minutes to prepare the first dish, and each following dish takes b minutes longer than the previous dish. There are a total of t minutes available to prepare the dishes.

For example, if the first dish takes a = 10 minutes and b = 5, then the second dish will take 15 minutes, the third dish will take 20 minutes, and so on.

If we have 80 minutes to prepare the dishes, then we can prepare four dishes because 10 + 15 + 20 + 25 = 70.

Write a program that prompts the user to enter the values of a, b, and t, and outputs the number of dishes that can be prepared in the allocated time t and the amount of time remaining (see Sample Run below).

Sample Run

Enter the number of minutes to prepare first dish: 6

Enter how many more minutes to prepare the next dish: 4

Enter the total time (in minutes) to prepare all the dishes: 57

In 57 minute(s) the pastry cook can prepare 4 dishes with 9 minutes unused.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.