Create A Menu and calculation of total amount(Function)

Hi.i'm a beginner to C++.And i have some problem with my C++ program that i need to calculate the total amount for a customer based on how many he/she has order.
However,i cnt think of hw to calculate the total amount.

I really appreciate if you could please help me with this problem

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

double Menu();
double Total(double, int, double);

double Menu()
{
	char choice;
	double rate;
	const double mocha=7.50;
	const double cappucino=9.20;
	const double icedCoffee=12.40;
	const double hotChocalate=10.90;

	cout<<setprecision(2)<<fixed;

	cout<<"Please select your drinks"<<endl;
	cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
	cout<<"1.Mocha"<<endl;
	cout<<"2.Cappucino"<<endl;
	cout<<"3.Iced Coffee"<<endl;
	cout<<"4.Hot Chocalate"<<endl;
	cin>>choice;

	switch(choice)
	{
	case'1':
		cout<<"You have select Mocha."<<"  Price="<<" RM "<<mocha<<endl;
		cin>>rate;
		break;
	case'2':
		cout<<"You have select Cappucino"<<"  Price="<<" RM "<<cappucino<<endl;
		cin>>rate;
		break;
	case'3':
		cout<<"You have select Iced Coffee"<<"  Price="<<" RM "<<icedCoffee<<endl;
		cin>>rate;
		break;
	case'4':
		cout<<"You have select Hot Chocalate"<<"  Price="<<" RM "<<hotChocalate<<endl;
		cin>>rate;
		break;
	default:
		cout<<"Invalid Choice!"<<endl;
		break;
	}
	
	return choice;

}

double Total(double rate, int ordernum, double sum)
{
	sum=ordernum*rate;
	
	
	
	return rate;

}

void main()
{
	double rate;
	int ordernum;
	double sum=0;
	char con;
	
	do 
	{

	rate=Menu();

	cout<<"How many drinks would you like? ";
	cin>>ordernum;

	sum= Total(rate, ordernum, sum);

	cout<<"Total amount is RM "<<sum<<endl;

	cout<<"Continue? y/n ";
	cin>>con;
	} while (con=='y');

	
}

Topic archived. No new replies allowed.