Coding Error Unidentified

Anyone can identify what's wrong with my code here? Please.


#include <iostream>
#include <cmath>
using namespace std;

void printMenu(); //function call
void balance();

void main()
{
int set,quantity ;
double total;
double amountPay;
double balance;

cout << "PLEASE ENTER SET NUMBER : ";
cin >> set;
cout << "PLEASE ENTER QUANTITY : ";
cin >> quantity;

switch (set);
{
case '1' : total = quantity * 7.50;

cout << "Total : " << total << endl;

break;
case '2' : total = quantity * 7.00;

cout << "Total : " << total << endl;

break;
case '3' : total = quantity * 6.50;

cout << "Total : " << total << endl;

default : cout << "\n Invalid selection " << endl;

}

cout << " MORE ORDERS ? (y/n) " << endl << endl;


cout << " Total : " << total << endl << endl;
cout << " Amount Pay : " << endl ;
cin >> amountPay;
cout << "Balance : " << balance << endl << endl;
cout << "BYE . . . " << endl;

}

void printMenu()
{

cout << "********************************\n";
cout << "WALLACE BURGER\n";
cout << "********************************\n";
cout << " -------------------------------\n";
cout << "MENU\n ";
cout << "--------------------------------\n";
cout << " 1 : CB, HP, SD (RM 7.50)\n ";
cout << " 2 : BB, FF, SD (RM 7.00)\n ";
cout << " 3 : FB, W, SD (RM 6.50)\n ";
cout << endl << endl;
}

void balance()
{
cout << "AMOUNT PAY : " << endl;
cin >> amountPay;

balance = amountPay - total;

return balance;
}
Please use code tags. http://www.cplusplus.com/articles/jEywvCM9/
You can edit your post, highlight your code and click the <> button on the right.

1
2
3
switch (set);
{
case '1' : total = quantity * 7.50;

You have a semi-colon after switch.
set is an integer whereas '1' is a character.

Please, use the code tags when you post the code. Hit Edit, highlight your code and hit <> under the format on the right side.
The following are the things I saw at first glanced.
Use int main() and not void main().
You created two functions, but you are not calling them.
On your function void balance(), you should not return on void functions.
You need to declare and initialize the variables balance, amountPay, total inside the balance() function.
Below is a link on functions tutorial.
http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.