161k views
0 votes
At a coffee shop, a coffee costs $1. Each coffee you purchase, earns one star. Seven stars earns a free coffee. In turn, that free coffee earns another star. Ask the user how many dollars they will spend, then output the number of coffees that will be given and output the number of stars remaining. Hint: Use a loop

User Carl Walsh
by
3.1k points

1 Answer

5 votes

Answer:

Step-by-step explanation:

The following is written in Python, no loop was needed and using native python code the function is simpler and more readable.

import math

def coffee():

dollar_amount = int(input("How much money will you be using for your purchase?: "))

free_coffees = math.floor(dollar_amount / 7)

remaining_stars = dollar_amount % 7

print("Dollar Amount: " + str(dollar_amount))

print("Number of Coffees: " + str(dollar_amount + free_coffees))

print("Remaining Stars: " + str(remaining_stars))

User Amuttsch
by
3.5k points