Ask Question
2 November, 08:58

Bianca 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. She has t minutes 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 she has 80 minutes to prepare the dishes, then she 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 Bianca can prepare.

+5
Answers (1)
  1. 2 November, 09:07
    0
    The solution code is written in Python:

    a = int (input ("Input first dish time: ")) b = int (input ("Input extra minutes: ")) t = int (input ("Input time available: ")) dishesCount = 1 currentTotal = a + b while (currentTotal < = t) : dishesCount + = 1 currentTotal + = currentTotal + b print ("Number of dishes can be prepared: " + str (dishesCount))

    Explanation:

    Firstly, prompt user to input the first dish time, extra minutes and time available and assign the values to variable a, b and t, respectively (Line 1-3).

    Next, create variable dishesCount to hold the number of dishes can be prepared (Line 5).

    Get the current total time by adding a and b and assign it to variable currentTotal (Line 6).

    While the currentTotal is less than or equal to t, increment the dishesCount by one and then add the hour of current dish to the currentTotal (Line 9-10).

    At last, display the number of dishes that can be prepared in t minutes (Line 12).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Bianca is preparing special dishes for her daughter's birthday. It takes her a minutes to prepare the first dish, and each following dish ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers