Coffee shop

A coffee shop would like to have a new cashier system. This coffee shop serves only three (3) types of drink:
Latte, Cappuccino, and Mocha. This program requires the cashier to enter the drink code and its unit. If the
drink to be purchased is less than 3, the cashier can just end the current session by entering any integer
(except the specified drink code) to the drink code. The program will provide the summary that includes drink
type, unit, total price without tax, tax amount and total price with tax.

1.A structure to keep the drinks information
Drink code, Drink name, Quantity, Price

2.Set a constant value for the price
Latte = 12.90, Cappuccino = 13.50, Mocha = 15.50

3.One function to set unit of each item

4.One function to calculate price for each coffee

5.An array of structure (created in #1) to capture those 3 drinks.

6.Display the summary of:
Order, Price of each drink type, Total price, Tax, Total price including tax

Only the structure and the summary that I'm sure I got it correct.

I don't know how to create the function to set unit of each coffee and the array of structure.
And am not sure of the function to calculate price for each coffee.

Help!!!

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
#include <iostream>
#include <iomanip>
#include <cstring>

using namespace std;

struct drinks_info
{
	int code;
	char dname[15];
	int unit;
	float price;
}Latte, Cappucino, Mocha;

int set_qty(struct drinks_info qty){
}

float calc(float x, int y){
	return x * y;
}

const float latte = 12.90;
const float cappucino = 13.50;
const float mocha = 15.50;

int main(){
	
	struct drinks_info type[5];
	
	//Latte info
	type[0].code = 101;
	strcpy(type[0].dname, "Latte");
	type[0].unit;
	type[0].price = 12.90;
	
	//Cappucino info
	type[1].code = 201;
	strcpy(type[1].dname, "Cappucino");
	type[1].unit;
	type[1].price = 13.50;
	
	//Mocha info
	type[2].code = 301;
	strcpy(type[2].dname, "Mocha");
	type[2].unit;
	type[2].price = 15.50;

	//set decimal places
	cout << fixed << setprecision(2);

	float total, tax;
	
	//Display Menu
	cout<< "***********" << endl
		<< "Coffee Shop" << endl
		<< "***********" << endl << endl
		<< type[0].code << " - " << type[0].dname << endl
		<< type[1].code << " - " << type[1].dname << endl
		<< type[2].code << " - " << type[2].dname << endl
		<< "_____________________________________" << endl << endl;
	
	//Input
	for(int i=0; i<3; i++){
		cout<< "Drink code: ";
		cin>> type[i].code;
		cout<< "Unit: ";
		cin>> type[i].unit;
					
		if ((type[0].unit + type[1].unit + type[2].unit < 3) && (type[i].code != 101 || type[i].code != 201 || type[i].code != 301)){
			exit;
		}
	}

	cout<< "_____________________________________" << endl << endl;
	
	//Summary
	cout<< "Drink Type"
		<< setw(11) << "Unit"
		<< setw(15) << "Price" << endl;
	cout<< "Latte"
		<< setw(15) << type[0].unit
		<< setw(16) << calc(type[0].price, type[0].unit) << endl;
	cout<< "Cappucino"
		<< setw(11) << type[1].unit
		<< setw(16) << calc(type[1].price, type[1].unit) << endl;
	cout<< "Mocha"
		<< setw(15) << type[2].unit
		<< setw(16) << calc(type[2].price, type[2].unit) << endl;
	
	total = calc(type[0].price, type[0].unit) + calc(type[1].price, type[1].unit) + calc(type[2].price, type[2].unit);
	
	cout<< "_____________________________________" << endl << endl;
	
	cout<< "Total Price: " << total << endl;
	
	cout<< "_____________________________________" << endl << endl;
	
	cout<< "Tax Amount: " << (tax = total * 0.06) << endl;
	
	cout<< "_____________________________________" << endl << endl;
	
	cout<< "Total Price (including tax): " << total + tax << endl;
	
	cout<< "_____________________________________";
}
Last edited on
closed account (48T7M4Gy)

This is what I have so far. Please tell me what I did wrong and what I need to add.

I think it might be easier to understand if you mentioned:

a) where in your program you are having trouble
b) what is going wrong for you - what do you expect vs what you got in terms of output.
Topic archived. No new replies allowed.