14,699,541 members
1.00/5 (1 vote)
See more:
Cash register, Pork shop 199B / person
Food prices in the restaurant, food 199, water 20, soft drinks 30, ice 20.

Input
1. table No
2. person
3. water
4. soft drink
5. Ice

Output
1.Table number
2. Food prices (number of people x199)
3. Beverage prices (x20 quantity + quantity x20 + quantity x20)
4. Total price and price per person to pay

What I have tried:

```#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
int id;
string N;
string s;
string r;
string k;
cout<<"table No\t: ";
cin>>N;
cout<<"person\t: ";
cin>>s;
cout<<"water\t: ";
cin>>r;
cout<<"soft drink\t: ";
cin>>k;
cout<<"Ice\t: ";
cin>>e;
cout<<"-------- OUTPUT--------\n"<<N<<" "<<s<<endl<<id<<" "<<r<<" "<<e;
_getch;
}```
Posted
Updated 25-Aug-20 21:49pm
v2
Patrice T 25-Aug-20 12:46pm

What is the problem/question ?

## Solution 2

Please don't use obsolete stuff like conio.h.
You are using the wrong types for your data and, basically, have tried nothing.
Try:
```#include <iostream>

using namespace std;

const int FoodPrice = 199;
const int BeveragePrice = 20;

struct TableInfo
{
int no;
int persons;
int waters;
int softdrinks;
int ices;
};

TableInfo input()
{
TableInfo ti;
cout << "please enter table no. ";
cin >> ti.no;
cout << "persons ";
cin >> ti.persons;
cout << "waters ";
cin >> ti.waters;
cout << "soft drinks ";
cin >> ti.softdrinks;
cout << "ices ";
cin >> ti.ices;
return ti;
}

void output( const TableInfo & ti )
{
cout << "table no. " << ti.no;
cout << "\npersons " << ti.persons;
int food_price = (ti.persons*FoodPrice);
cout << "\nfood price " << food_price;
int beverages_price =   (ti.waters + ti.softdrinks + ti.ices) * BeveragePrice;
cout << "\nbeverages price " << beverages_price;
int total_price = food_price + beverages_price;
cout << "\ntotal price " << total_price;
int price_per_person = (total_price / ti.persons);
if ( price_per_person * ti.persons < total_price)
++price_per_person; // melius abundare quam deficere
cout << "\nprice per person " << price_per_person << endl;
}

int main()
{
TableInfo ti = input();
cout << "-------------------\n";
output(ti);
getchar();
}```

## Solution 1

We have no idea: we don;t know what your teacher has asked you to do and your notes above are ... um ... cryptic.

So go back to the question, read it really carefully, and try to do it manually on paper. When you have it sorted in you mind that way, you should be able to start thinking about how to implement it.

Do that in stages: one small step at a time. Design it, code, test it. When it works, move on to the next step. If it doesn't, us eteh debugger to find out why.

You'll get there - just take it in small steps and you'll do it pretty quickly.
CPallini 26-Aug-20 2:25am

Have my 5.