Restaurant bill

I need to write a program in c++ that will calculate the amount each person owes. It needs to first ask how many customers at the table. Then ask for the price of each meal. Then the program must produce the subtotal, tax and tip of the bill in money format. Sales tax is 6% and the tip is 18% on tables less than 5 people but 20% on tables more than 5 people. All need to be inculeded in the subtotal. Program should continue processing till amount of people at the table is 0. If you can help that would be awesome! I’m so lost...
Let's start by making a list of what things we know and what we need to do.

So we need to know these things from the user:
1) How many customers are at the table
2) The money each person at the table owes to the restaurant
3) What meals each person at the table had eaten (also ask how many of that meal)
4) Price of each meal eaten by each person

What we need to calculate:
1) Subtotal
2) Tax (6%)
3) Tip (if more than 5 people then 20% otherwise 18%)
4) Total

The output should look something like this, either you print each customer's bill separately while including meals(I guess that's what they want us to do because they are asking how much money each person owes separately otherwise) and then the subtotal, tax, tip, total. Otherwise you can display each meal separately and then display subtotal etc. (that's how it's supposed to work but I guess it's better you do the previous option).

So output would be like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Customer 1:
  Cockroach legs x2 - 1400 bitcoins
  Insect feces x 1 - 5030 bitcoins
Total:- 5430 bitcoins

Customer 2:
  Cockroach eyes x 2 = 1400 bitcoins
  Insect overload x 1 - 20 bitcoins
Total:- 1420 bitcoins

Subtotal:- 6850 bitcoins
tax:- ...
tip:- ...
Total:- ...

What if I don't want to give a tip.. no fair.


Now that you what to do, try to come up with what logic you will use. Hmm what might come handy over here.. for-loops?

After you're done post your code in [code] [ /code] CODING TAGS (pls don't forget the tags) and then we'll correct you if you get it wrong.
Is there any way to use a loop command for customers?
Yes that's what the question wants you to do.

-> First get how many customers there are.
-> Then use a for-loop from 1 to <= #customers

Inside the for-loop ask for the respective information you need to gather from each customer. And use vectors to store information (you might need to use a structure if you're going to get the meals of each person).

You can either use a structure or forget about having to store meals consumed by each person itself and collectively store all the meals ordered in a different vector then you don't need to use a structure, and I think that's how you were supposed to do this (it's fine even if you do it like how I showed in the sample output).
Last edited on
Topic archived. No new replies allowed.