BillingSystem program(Help!)

write a program to help a local restaurent automate its breakfast billing system. The program should do the following:
a)show the different items offered by the restaurent
b)allow the customer to select more than one item from the menu.
c)calculate and print the bill. Items:
Plain Egg 		1.45
Bacon and Egg		2.45
Muffin 			.99
French Toast 		1.99
Fruit Basket 		2.49
Cereal 			.69
Coffee 			.5
Tea 			.75


I've decided to use a struct to store the name and price, and an array of structs to represent every item. Problem is i dont know how to go about splitting the input read from the file into the name and price seperatly. Can anyone help?
**Please dont just give me code, idealy i wouldnt like any code at all. I just need to know how i would go about assigning each struct element its proper information.

Here is what i have right now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
#include <fstream>
#define NUM_ITEMS 8

struct menuItemType
{
    std::string Name;
    float Price;
};
void getData(menuItemType menuList[]);
void showMenu();
void printCheck();
int main()
{
    menuItemType menuList[NUM_ITEMS];
    getData(menuList);
    std::cout << "Restaurant Billing System: please select the items you wish to purchase\n";
    std::cout << menuList[0].Name;

}
void getData(menuItemType menuList[])
{
    char  temp[256];
    std::ifstream File("MenuItems.txt");
    for(int i = 0; i < NUM_ITEMS; i ++)
    {
        File.getline(temp,256, '\n'); //how do i split this into price and name after?
        menuList[i].Name = temp;
    }
    File.close();
}
Last edited on
assuming there is a '\t' "tab" after each of the strings, you can just go
getline(file, your_array, '\t');
and followed by a
file >> your_integer;
Topic archived. No new replies allowed.