Write a python program to figure out how to split a restaurant bill. Your program should prompt the user for the following information: The total amount of the bill, a float. The percentage everyone is willing to tip, a float between 0 and 1. So 0.2 would be entered for a 20% tip. The number of ways to split the bill (i.e. the number of people in the group), an integer. The program should use the information supplied by the user to calculate how much each person should contribute. For example, if the total bill was $60.00, everyone is willing to tip 20% (0.2), and there are 3 people willing to split the bill, then each person should contribute $24. The program should then print that amount for the user. Avoid prompting the user for input or printing to console from inside of any function other tha

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a python program to figure out how to split a restaurant bill.

Your program should prompt the user for the following information:

  • The total amount of the bill, a float.

  • The percentage everyone is willing to tip, a float between 0 and 1. So 0.2 would be entered for a 20% tip.

  • The number of ways to split the bill (i.e. the number of people in the group), an integer.

    The program should use the information supplied by the user to calculate how much each person should contribute. For example, if the total bill was $60.00, everyone is willing to tip 20% (0.2), and there are 3 people willing to split the bill, then each person should contribute $24. The program should then print that amount for the user.

Avoid prompting the user for input or printing to console from inside of any function other than main(). Using the following tips:

  1. Instead of prompting for input inside a function, prompt for input inside main(), assign the user’s input to a variable, then pass that variable to your function as a parameter.

  2. Instead of printing to the console inside a function, return the data to be printed, call your function from main(), assign the output to a variable, then print the variable.

  3. Are you printing to the console multiple times in a function? Split that function into multiple smaller functions – at least one for each print().

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education