Need some help with variables..

Hi , im new in learning c++
i need few thing to clarify . I know variables if it was declare one by one , but this coding is confusing..

im confused , what is the input variables for this coding ?
is it choice or userinput() ?

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
  #include <iostream>
using namespace std;

int total1 = 0, total2 = 0, total3 = 0;
float pItem1 , pItem2 , pItem3;
char option ;
char repeat;
char userInput();
char printSummary();

int main()
{

    pItem1=1.5 ;
    pItem2=3 ;
    pItem3=2 ;
{

    do
    {



	cout<<"\n--------------------------"<<endl;
	cout<<"Welcome To Cashier System"<<endl;
	cout<<"--------------------------"<<endl;
	cout<<"[1] ice cream - RM "<<pItem1<<endl;
	cout<<"[2] cake - RM "<<pItem2<<endl;
	cout<<"[3] fruit juice - RM "<<pItem3<<endl;
	cout<<"[4] print summary"<<endl;
	cout<<"[5] exit order & print receipt"<<endl<<endl;

	userInput();

	cout<<"Do you want to retake your order ? : ";
	cin>>repeat;
}
while
    (repeat=='y'||repeat=='Y');
    {
        cout<<"Bye !!!";

    }
}
}

char userInput() {

	char choice;
	int t1 = 0, t2 = 0, t3 = 0;
	float tPrice = 0;
	int x = 1;


	for (int i=0;i<=3;i++)
        {

		cout<<"Enter your choice : ";
		cin>>choice;


	if (choice == '1') {
		if (t1 == 0) {
			t1 = t1 + 1;
			total1 =  total1 + 1;
		}
		else {
			cout<<"Ice cream already taken.\nPlz select another item."<<endl;
			i = i -1 ;
		}
	}

	else if (choice == '2') {
		if (t2 == 0) {
			t2 = t2 + 1;
			total2 =  total2 + 1;
		}
		else {
			cout<<"Cake already taken.\nPlz select another item."<<endl;
			i = i -1 ;
		}
	}

	else if (choice == '3') {
		if (t3 == 0) {
			t3 = t3 + 1;
			total3 =  total3 + 1;
		}
		else {
			cout<<"Fruit juice already taken.\nPlz select another item."<<endl;
			i = i -1 ;
		}
	}

	else if (choice == '4') {
		printSummary();
		break;
	}

	else if (choice == '5') {
        break;
	}

	}
	//end for

	cout<<"\nReceipt"<<endl;
	cout<<"-------"<<endl;

	if (t1 == 1) {
		cout<<x<<". Ice cream - RM "<<pItem1<<endl;
		tPrice = tPrice + pItem1;
		x = x + 1;
	}

	if (t2 == 1) {
		cout<<x<<". Cake - RM "<<pItem2<<endl;
		tPrice = tPrice + pItem2;
		x = x + 1;
	}

	if (t3 == 1) {
		cout<<x<<". Fruit juice - RM "<<pItem3<<endl;
		tPrice = tPrice + pItem3;
		x = x + 1;
	}

	cout<<"Total price : RM "<<tPrice<<endl;
	cout<<"\nThank you for using cashier system.\n\n"<<endl;


}

char printSummary() {

	cout<<"\nSummary"<<endl;
	cout<<"-------"<<endl;
	cout<<"Total ice cream sale : RM "<<total1 * pItem1<<endl;
	cout<<"Total cake sale : RM "<<total2 * pItem2<<endl;
	cout<<"Total fruit juice sale : RM "<<total3 * pItem3<<endl;
return 0;
}
here... choice is the input variable
userinput() is the function asking for choice three times as your food items could be maximum 3
Topic archived. No new replies allowed.