220k views
0 votes
programmning You are asked to develop a cash register for a fruit shop that sells oranges and apples. The program will first ask the number of customers. Subsequently, for each customer, it will ask the name of the customer and the number of oranges and apples they would like to buy. And then print a summary of what they bought along with the bill as illustrated in the session below: How many customers? 2 Name of Customer 1 Harry Oranges are $1.40 each. How many Oranges? 1 Apples are $.75 each. How many Apples? 2 Harry, you bought 1 Orange(s) and 2 Apple(s). Your bill is $2.9 Name of Customer 2 Sandy Oranges are $1.40 each. How many Oranges? 10 Apples are $.75 each. How many Apples? 4 Sandy, you bought 10 Orange(s) and 4 Apple(s). Your bill is $17.0

1 Answer

0 votes

Solution:

def main():

n=int(input("How many customers? "))

print()

# User input of the fruit requirement of all customers.

for i in range(n):

print("Name of Customer",i+1)

name = input()

print("Oranges are $1.40 each. How many Oranges?")

no_of_orange = int(input())

print("Apples are $.75 each. How many Apples?")

no_of_apple = int(input())

print(name,", you bought",no_of_orange,"Orange(s) and",no_of_apple,"Apple(s).")

# Calculation of total bill

total_bill = (no_of_orange*1.40) + (no_of_apple*0.75);

#Print total_bill

print("Your bill is $",total_bill,end="");

print("\\");

if __name__=="__main__":

main()

User Miguel Salas
by
5.7k points