Question about negative tender in my output

wondering why at the end of my program the tender is showing negative...

#include <iostream>

#include <iomanip>
using namespace std;
void showMenu();

void displayBill(float bill, float totalBill, float& tip, float& taxDue);

void displayChange(float amtTendered, float amtChangeDue);

float bill, totalBill, amtTendered, amtChangeDue, taxDue, tipDue;

int main()

{
//constants for menu items

const int hamburgerPrice = 6;

const float hotdogPrice = 4.5;

const float peanutsPrice = 3.75;

const float popcornPrice = 5.5;

const float sodaPrice = 2.8;

const int chipsPrice = 1;

const int waterPrice = 2;

//tax constant

const float tax = 0.054;

const float tip = 0.20;

//total variables

char menuChoice;

float bill = 0;

void showMenu();

{

cout << "Baseball Game Snack Menu" << endl;

cout << "1 - hamburger $6.00" << endl;

cout << "2 - Hotdog $4.50" << endl;

cout << "3- Peanuts $3.75" << endl;

cout << "4 - Popcorn $5.50" << endl;

cout << "5 - Soda $2.80" << endl;

cout << "6 - Chips $1.00" << endl;

cout << "7 - Water $2.00" << endl;

cout << "8 - END ORDER" << endl;

}



cout << "Enter menu item: \n";

cin >> menuChoice;

do
{
switch (menuChoice)
{

case '1':

bill = bill + hamburgerPrice;

cout << "Enter menu item: \n";

cin >> menuChoice;
break;
case '2':
bill = bill + hotdogPrice;
cout << "Enter menu item: \n";

cin >> menuChoice;

break;

case '3':

bill = bill + peanutsPrice;

cout << "Enter menu item: \n";

cin >> menuChoice;

break;

case '4':

bill = bill + popcornPrice;

cout << "Enter menu item: \n";

cin >> menuChoice;

break;

case '5':

bill = bill + sodaPrice;

cout << "Enter menu item: \n";

cin >> menuChoice;

break;

case '6':

bill = bill + chipsPrice;
cout << "Enter menu item: \n";

cin >> menuChoice;

break;

case '7':

bill = bill + waterPrice;

cout << "Enter menu item: \n";

cin >> menuChoice;

break;
case '8':

exit(0);

default:

cout << "You did not enter a menu item! (1-8):";

cin >> menuChoice;

break;
}
} while (menuChoice < '8');

void displayBill(float& bill, float totalBill, float& tip, float taxDue);
{

float taxDue = bill * tax;

float tipDue = bill * tip;

float totalBill = bill + taxDue + tipDue;8

cout << setprecision(3) << "Bill = $" << bill << endl;

cout << "Tax = " << taxDue << endl;

cout << "Tip = " << tipDue << endl;

cout << setprecision(3) << "Total amount due: $" << totalBill << endl;

}
void displayChange(float& amtTendered, float amtChangeDue);
{

cout << "Enter Amount Tendered: " << endl;
cin >> amtTendered;

if (amtTendered < (bill + tip + tax))

{
cout << "Please enter enough to cover total bill" << endl;

cin >> amtTendered;
}

else

{
amtChangeDue = totalBill - amtTendered;
cout << "Change Due: $" << amtChangeDue << endl;
}
}
system("pause");
return 0;
}
Last edited on
Please only post questions ONCE

http://www.cplusplus.com/forum/beginner/224535/
Topic archived. No new replies allowed.