I'm in desperate need of help!

I've been trying to fix my problem but i'm just in a shortage of time (5 hours to be exact) So I don't have that much time so please can anyone please help by editing my code for me. I have several problems but don't know what to do.

1] Program cannot read from the text file for the items to be calculated and print out in the receipt
2]My program has to be user friendly but i really don't know what to do with that one.

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>

using namespace std;

ifstream Read;
string Item;
int Amount = 1;
double Total = 0;
double Price = 0.0;
double Tip = 0.0;
double GrandTotal = 0;

struct Menuitem 
{
    string name;
    double Price;
};

vector <Menuitem> menu;

void Welcome_Message()
{
    cout << "\n\t\tHELLO AND WELCOME TO TI.LAUME PIZZERIA!\t\t\n";
    cout << "\t\t========================================\t\t" << endl;
    cout << "\n\t\tTHE PLACE WHERE ALL YOUR PIZZA DESIRES\t\t\n";
    cout << "\t\tARE QUENCHED BY OUR DELICIOUS PIZZAS!\t\t" << endl;
    cout << "\t\t========================================\t\t" << endl;
    cout << endl << endl;    
}

void LoadMenu()
{
    ifstream Read("store.txt");
    Menuitem Item = {"", 0};
    
    menu.push_back(Item);
            
    while (getline(Read, Item.name, '#') && Read >> Item.Price)
    {
        Read.ignore(100, '\n'); 
        menu.push_back(Item);
    }
    
}

void Menu()
{
    cout << "\t~PIZZA MENU~\t" << endl;
    cout << "########################" << endl;

    for (size_t i = 1; i<menu.size(); ++i)    
    {
        cout << "  " << i << "  "
             << left  << setw(15) << menu[i].name
             << '$' << setw(2) << menu[i].Price
             << '\n'; 
    }
    cout << "########################" << endl;    
}
void Receipt()
{
	cout << endl << endl;
	cout << "\n=========================================\n";
	cout << "\tReceipt\t";
    Read.close();
    cout << "\n-----------------------------------------\n";
    cout << "Your total is: $" << Total << setprecision(5) << endl;
    cout << "Your tip is: $" << Tip << setprecision(3) << endl;
    cout << "\n----------------------------\n";
    cout << "Yout grand total is: $" << GrandTotal << setprecision(4) << endl;
    cout << "----------------------------";
    cout << endl ;
    cout << "Thank You for choosing Ti Laume Pizzeria!" << endl;
    cout << "\n-----------------------------------------\n";
    cout << endl;
    
}

void Logic()
{
	char Another = ' ';
	Another = 'y';
    while(Another == 'y')
    {
    			cout << endl;
                  cout << "What would you like to order?: ";
                  getline(Read, Item);
                  Read >> Price;
                  cin >> ();
                  cout << "Please enter the amount of the Item you intend to purchase: ";
                  cin >> Amount;
                  cout << "Do you want to order another Item (y/n)? ";
                  cin >> Another;
                  
                  Total = Amount * Price;
                  Tip = Total * 0.15;
                  GrandTotal = Total + Tip;
    }
	
}
int main()
{
    Welcome_Message() ;
    LoadMenu();    
    Menu();
    Logic();
    Receipt();

return 0;
}


text file Store.txt
1
2
3
4
5
6
7
8
9
CheeseBurger#5
DeluxeBurger#12
SmallPizza#7
MediumPizza#12
LargePizza#18
FamilyPizza#27
Coke#2.50
Sprite#2.50
Fanta#2.50 


If LoadMenu() is not working I would try separating the actions in several steps. That way you can determine which step is actually causing the problem and focus on fixing that.

In my opinion your LoadMenu function does:
1. read a line from a file into a string (http://www.cplusplus.com/forum/general/211397/)
2. find the # in the string (http://www.cplusplus.com/reference/string/string/find/)
3. create a substring containing the name of the item (http://www.cplusplus.com/reference/string/string/substr/)
4. create a substring containing the price of the item
5. convert the string with the price to a double (http://www.cplusplus.com/reference/string/stod/)
6. Create an MenuItem object with the name and the value
7. Store a pointer to the MenuItem object in the vector menu

As for user friendly, I think that will always be debatable. Being asked how many things you want to by or if you want to buy something else might be considered user friendly in this case.

Knd regards, Nico
This looks very much like some code which I suggested a couple of days ago.

I kind of assumed it wasn't suitable. Since you decided to try it, then you need to fill in some missing pieces.

I suspect the intention behind the code I began wasn't fully grasped - which is unfortunate since time is so short now.

My version of the logic function looked like this:
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
double Logic(ostringstream & receipt)
{
    char Another = 'y';
    
    int Number   = 0;
    int Amount = 0;    
    
    double Total = 0;
    
    while (Another == 'y')
    {
        cout << endl;
        cout << "What would you like to order?: ";
        cin  >> Number;
        cout << "Please enter the amount of the item you intend to purchase: ";
        cin  >> Amount;
        cout << "Do you want to order another item (y/n)? ";
        cin  >> Another;
        
        double cost = Amount * menu[Number].price;          
        Total = Total + cost;
        
        receipt << Amount << " " << setw(15) << menu[Number].name << " $" << cost << '\n';
        
    }
    
    return Total;
	
}


It works very much in partnership with the vector which was created in the loadmenu function. The stringstream is an added idea I had - but I fear it may add confusion. It was a way of generating some of the text of the receipt right there, but the receipt itself won't be printed until later.

In main() you'd call it like this:
1
2
3
4
5
6
7
    Welcome_Message() ;
    LoadMenu();   
     
    Menu();
    ostringstream receipt;
    double Total = Logic(receipt);
    Receipt(Total, receipt);

The logic function returns the total so far. Then the receipt function can use the value to calculate the tip and the final total.

I hope this is of some use but I'm concerned that it may be already past the deadline. If there are questions, please ask.

Thank you all for your help! This assignment was really tedious and complicated due to the fact that i'm illiterate when it comes to coding. Thank you Chervil you have been the most help throughout my project and everyone one else for trying!!!
Topic archived. No new replies allowed.