Output is incorrect. Help?

Well I'm pretty new at using structs. I get the hang of it for other programs but I can't seem to get the correct output for this one. I'm using DevC++ for this, I'm not sure whether it's either my arrangements got a problem or the IDE.

Anyways, here's the program:
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <iostream>
#include <conio.h>
#include <string.h>

using namespace std;

struct menu{
	char menu[50];
	double price;
	int quantity;
	double totalprice1 ;
	double totalprice2 ;
};

int showMenu(menu,menu,menu,menu,menu,menu,menu,menu);
int CalculateTotal(menu,int,double);
int printCheck(menu,int,double);

int main(){
	
	menu a,b,c,d,e,f,g,h;
	
	strcpy(a.menu, "Plain egg + coffee");
	a.price = 2.45;
	
	strcpy(b.menu, "Fried chicken and egg + coffee");
	b.price = 5.45;
	
	strcpy(c.menu, "Muffin + tea");
	c.price = 3.99;
	
	strcpy(d.menu, "French toast + tea");
	d.price = 2.99;
	
	strcpy(e.menu, "Fruit Basket + juice");
	e.price = 2.49;
	
	strcpy(f.menu, "Cereal + milk");
	f.price = 2.69;
	
	strcpy(g.menu, "Coffee");
	g.price = 1.00;
	
	strcpy(h.menu, "Tea");
	h.price = 0.80;
	
	
	cout << "\t\t\t\tWelcome to" << endl ;
	cout << "\t\t\t     Jonny's Place" << endl ;
	cout << "\t\t\t     =============" << endl ;
	getch();
	system("cls");
	showMenu(a,b,c,d,e,f,g,h); 
	
	getch();

}

int showMenu(menu a, menu b, menu c, menu d, menu e, menu f, menu g, menu h){
	
	char choice;
	int quantity = 0;
	double tax = 0;
	
	while(choice != 'x'){
		system("cls");
		cout << "Menu" <<endl ;
		cout << "----" << endl;
		cout << endl ;
		cout << "A. Plain egg + coffee (RM2.45)" << endl ;
		cout << "B. Fried chicken and egg + coffee (RM5.45)" << endl ;
		cout << "C. Muffin + tea (RM3.99)" << endl ;
		cout << "D. French toast + tea (RM2.99)" << endl ;
		cout << "E. Fruit Basket + juice (RM2.49)" << endl ;
		cout << "F. Cereal + milk (RM2.69)" << endl ;
		cout << "G. Coffee (RM1.00)" << endl ;
		cout << "H. Tea (RM0.80)" << endl ;
		cout << endl ;
		cout << "Which breakfast item do you desire (enter 'x' to exit): " ;
		cin >> choice;
		
		system("cls");
		cout << "You have selected: " << endl ;
		switch (choice){
			case 'a': cout << a.menu << endl ;
				 		   cout << "Price : RM" << a.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
   						   CalculateTotal(a,quantity,tax);
				 		   printCheck(a,quantity,tax);
				 		   break;
            case 'b': cout << b.menu << endl ;
				 		   cout << "Price : RM" << b.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(b,quantity,tax);
				 		   printCheck(b,quantity,tax);
				 		   break;
            case 'c': cout << c.menu << endl ;
				 		   cout << "Price : RM" << c.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(c,quantity,tax);
				 		   printCheck(c,quantity,tax);
				 		   break;
            case 'd': cout << d.menu << endl ;
				 		   cout << "Price : RM" << d.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(d,quantity,tax);
				 		   printCheck(d,quantity,tax);
				 		   break;
            case 'e': cout << e.menu << endl ;
				 		   cout << "Price : RM" << e.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(e,quantity,tax);
				 		   printCheck(e,quantity,tax);
				 		   break;
            case 'f': cout << f.menu << endl ;
				 		   cout << "Price : RM" << f.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(f,quantity,tax);
				 		   printCheck(f,quantity,tax);
				 		   break;
			case 'g': cout << g.menu << endl ;
				 		   cout << "Price : RM" << g.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(g,quantity,tax);
				 		   printCheck(g,quantity,tax);
				 		   break;
			case 'h': cout << h.menu << endl ;
				 		   cout << "Price : RM" << h.price << endl ;
				 		   cout << endl ;
				 		   cout << "How much do you want: " << endl ;
				 		   cin >> quantity;
				 		   CalculateTotal(h,quantity,tax);
				 		   printCheck(h,quantity,tax);
				 		   break;	
			case 'x': cout << "to exit" <<endl ;
			 	 	  cout << endl ;
					  cout << "Thank you" << endl ;				 		   
		}
		
		
	}
	
}

int CalculateTotal(menu x, int quantity, double tax){
	x.totalprice1 = x.price * quantity;
	tax = x.totalprice1 * (5/100);
	x.totalprice2 = x.totalprice1 + tax;
	return x.totalprice1,x.totalprice2, tax;
}

int printCheck(menu x, int quantity, double tax){
	system("cls");
	cout << "Thanks for dining at Jonny's Place" << endl ;
	cout << "----------------------------------" << endl ;
	cout << endl ;
	cout << x.menu << "   " << quantity << "   RM" << x.totalprice1 << endl ;
	cout << "Tax 							   RM" << tax << endl ;
	cout << endl ;
	cout << "Amount Due						   RM" << x.totalprice2 << endl ;
	
	getch(); 
}
What is "correct output"?

What output are you getting?
What output are you expecting?
What input do you have to provide to get that output?
Topic archived. No new replies allowed.