Click here to Skip to main content
14,699,541 members
Please Sign up or sign in to vote.
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.

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

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:


using namespace std;

int main()
    int id;
    string N;
    string s;
    string r;
    string k;
    cout<<"table No\t: ";
    cout<<"person\t: ";
    cout<<"water\t: ";
    cout<<"soft drink\t: ";
    cout<<"Ice\t: ";
    cout<<"-------- OUTPUT--------\n"<<N<<" "<<s<<endl<<id<<" "<<r<<" "<<e;
Updated 25-Aug-20 21:49pm
Patrice T 25-Aug-20 12:46pm
What is the problem/question ?

Please don't use obsolete stuff like conio.h.
You are using the wrong types for your data and, basically, have tried nothing.
#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 >>;
  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. " <<;
  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";
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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900