I am a first-year college student and I am currently having trouble with this program I am working on, It is about a billing system. I managed to do everything but the final part, which is printing the total, tax, and the final bill. Anything I try to do either gives me a wrong answer or a 0. Please help.
#include <iostream>
#include <string.h>
#include <iomanip>
#define MAX 8
using namespace std;
struct menuItemType{
string menuItem;
double menuPrice;
};
menuItemType menulist[MAX];
void getData();
void showMenu();
int printCheck(void);
//int b[8] = {0,0,0,0,0,0,0,0};
int main(){
cout << "Welcome to Mavel's Restaurant\n\n";
cout << "------------ Menu ------------ \n";
showMenu();
getData();
int choice;
char add;
do {
cout << "Enter choice: ";
cin >> choice;
switch (choice){
case 1:
cout<< "You ordered Plain Egg.\n";
break;
case 2:
cout<< "You ordered Bacon and Egg.\n";
break;
case 3:
cout<< "You ordered a muffin.\n";
break;
case 4:
cout<< "You ordered French Toast.\n";
break;
case 5:
cout<< "You ordered Fruit Basket.\n";
break;
case 6:
cout<< "You ordered Cereal.\n";
break;
case 7:
cout<< "You ordered Coffee.\n";
break;
case 8:
cout<< "You ordered Tea.\n";
break;
default:
cout<< "Invalid Choice.";
break;
}
cout<< "Would you like to order another item? [Y]es / [N]o : ";
cin >> add;
if (add == 'N'||add =='n'){
printCheck();
}
}
while (add == 'Y'|| add == 'y');
}
void getData(){
menulist[0].menuItem = "Plain Egg";
menulist[0].menuPrice = 140.50;
menulist[1].menuItem = "Bacon and Egg";
menulist[1].menuPrice = 245.00;
menulist[2].menuItem = "Muffin";
menulist[2].menuPrice= 295.00;
menulist[3].menuItem = "French Toast";
menulist[3].menuPrice = 495.00;
menulist[4].menuItem = "Fruit Basket";
menulist[4].menuPrice = 555.00;
menulist[5].menuItem = "Cereal";
menulist[5].menuPrice = 385.00;
menulist[6].menuItem = "Coffee";
menulist[6].menuPrice = 415.00;
menulist[7].menuItem = "Tea";
menulist[7].menuPrice = 333.00;
}
void showMenu(){
cout << "[1] Plain Egg\t\tPhp140.50\n";
cout << "[2] Bacon and Egg\tPhp245.00\n";
cout << "[3] Muffin\t\tPhp295.00\n";
cout << "[4] French Toast\tPhp495.00\n";
cout << "[5] Fruit Basket\tPhp555.00\n";
cout << "[6] Cereal\t\tPhp385.00\n";
cout << "[7] Coffee\t\tPhp415.00\n";
cout << "[8] Tea\t\t\tPhp333.00\n\n";
}
double total = 0;
int printCheck(){
getData();
double total = 0 , tax, totalbill;
for (int i = 0; i < 8; i++){
total += menulist[i].menuPrice;
}
tax = total * 0.05;
totalbill = total+tax;
cout << "----------------------------------------------\n";
cout << "Tax\t\t" << tax<< endl;
cout << "Amount Due\tPhp" << totalbill << endl;
cout << "----------------------------------------------\n";
return total;
}