I am writing a program that lists a breakfast menu with prices and lets the user make an order. I am stuck on a few points and need some advice to get the program to run correctly.
The first problem, I can only get amount due to calculate the tax. And the tax rate does not seem to be calculating the order properly eithier. I also need a loop to ask the user to if they want to select another item and if so keep the order processing if not then calculate what has been ordered. Oh and items such as tea and coffee output with an extra zero after the price (.750) when it should be just (.75).I have seen various ways others have done this program on this site. But I would rather figure the process out on my own. And, right now I am stuck!

#include <iostream> 
#include <string> 
#include <iomanip> 
void showMenu(); 

using namespace std; 

const int menu = 1; 

struct menuItemType 

{ 
   string menuItem; 
   double menuPrice; 
}; 

void getData(menuItemType placeorder[8]); 
void printCheck(menuItemType printorder[]); 

int main() 

{ 
    cout <<"Welcome to Johnny's Restaurant"<< endl;
    cout <<"----Today's Menu----"<< endl; 
    showMenu();
    cout << endl;
    cout << "You can make up to 8 single order selections"<<endl; 
    cout << "Do you want to make a selection Y/y (Yes). N/n (No): ";
    char selection;
    cin >> selection;
    if (selection == 'Y' || selection == 'y')
    {
                    
    menuItemType menuList[8]; 
    menuItemType order[8]; 
    getData(order); 
    printCheck(order); 

    int choices = 8;
    }
    else (selection != 'Y' || selection != 'y');
    {
         
         }
                  
    system("PAUSE");
    return 0; 
} 

void showMenu() 
{  
	cout << "1: Plain Egg.................$ 1.45" << endl; 
	cout << "2: Bacon and Egg.............$ 2.45" << endl; 
	cout << "3: Muffin....................$ 0.99" << endl; 
	cout << "4: French Toast..............$ 1.99" << endl; 
	cout << "5: Fruit Basket..............$ 2.49" << endl; 
	cout << "6: Cereal....................$ 0.69" << endl; 
	cout << "7: Coffee....................$ 0.50" << endl; 
	cout << "8: Tea.......................$ 0.75" << endl; 
} 
 
void getData(menuItemType placeorder[8]) 
{ 
	menuItemType menuList[8]; 
	menuList[0].menuItem = "Plain Egg     ";      
	menuList[1].menuItem = "Bacon and Egg "; 
	menuList[2].menuItem = "Muffin        ";          
	menuList[3].menuItem = "French Toast  ";      
	menuList[4].menuItem = "Fruit Basket  "; 
	menuList[5].menuItem = "Cereal        "; 
	menuList[6].menuItem = "Coffee        "; 
	menuList[7].menuItem = "Tea           "; 

	menuList[0].menuPrice = 1.45; 
	menuList[1].menuPrice = 2.45; 
	menuList[2].menuPrice = 0.99; 
	menuList[3].menuPrice = 1.99; 
	menuList[4].menuPrice = 2.49; 
	menuList[5].menuPrice = 0.69; 
	menuList[6].menuPrice = 0.50; 
	menuList[7].menuPrice = 0.75; 
	
    cout << endl; 
    
    
 for (int x=0; x<3; x++) 
   { 
	
    cout << " " << endl;
    int answer; 
    cout << "Enter item number: ";
    cin >> answer; 
    cout << "Select another item Y/y (Yes), N/n (No): "; 
    char selectionTwo; 
    cin >> selectionTwo; 
    placeorder[x].menuItem = menuList[answer-1].menuItem; 
    placeorder[x].menuPrice = menuList[answer-1].menuPrice; 
   } 
} 
 
void printCheck(menuItemType printorder[]) 
{ 
	const double taxRate = 0.05; 
	int x = 0;
	double amtDue = 0;
	double tax = 0; 
	
	cout << endl;
	cout << endl;
	cout << endl;

 
	cout << "Welcome to Johnny's Restaurant" << endl;  
	cout << endl;

	for (x=0; x<3; x++) 
	{ 
	cout.precision(3);
	cout << showpoint;
	tax += (printorder[x].menuPrice) * taxRate;
	cout << printorder[x].menuItem << setw(13) << "$ " << printorder[x].menuPrice << endl; 
	}

	cout.precision(2);
	cout << showpoint;
	cout<<"Tax                      $ " << tax << endl; 
	cout.precision(2);
	amtDue += (printorder[x].menuPrice) + tax;
	cout << showpoint;
	cout<<"Amount Due               $ " << amtDue << endl;
	

}
#include <iostream> 
#include <string> 
#include <iomanip> 
void showMenu(); 

using namespace std; 

const int menu = 1; 

struct menuItemType 
{ 
   string menuItem; 
   double menuPrice; 
}; 

void getData(menuItemType placeorder[8]); 
void printCheck(menuItemType printorder[]); 

int main() 

{ 
    cout <<"Welcome to Johnny's Restaurant"<< endl;
    cout <<"----Today's Menu----"<< endl; 
    showMenu();
    cout << endl;
    cout << "You can make up to 8 single order selections"<<endl; 
    cout << "Do you want to make a selection Y/y (Yes). N/n (No): ";
    char selection;
    cin >> selection;
    if (selection == 'Y' || selection == 'y')
    {                    
        menuItemType menuList[8]; 
        menuItemType order[8]; 
        getData(order); 
        printCheck(order); 

        int choices = 8;
    }
    else (selection != 'Y' || selection != 'y');
    {     
    }
                  
    system("PAUSE");
    return 0; 
} 

void showMenu() 
{  
	cout << "1: Plain Egg.................$ 1.45" << endl; 
	cout << "2: Bacon and Egg.............$ 2.45" << endl; 
	cout << "3: Muffin....................$ 0.99" << endl; 
	cout << "4: French Toast..............$ 1.99" << endl; 
	cout << "5: Fruit Basket..............$ 2.49" << endl; 
	cout << "6: Cereal....................$ 0.69" << endl; 
	cout << "7: Coffee....................$ 0.50" << endl; 
	cout << "8: Tea.......................$ 0.75" << endl; 
} 
 
void getData(menuItemType placeorder[8]) 
{ 
	menuItemType menuList[8]; 
	menuList[0].menuItem = "Plain Egg     ";      
	menuList[1].menuItem = "Bacon and Egg "; 
	menuList[2].menuItem = "Muffin        ";          
	menuList[3].menuItem = "French Toast  ";      
	menuList[4].menuItem = "Fruit Basket  "; 
	menuList[5].menuItem = "Cereal        "; 
	menuList[6].menuItem = "Coffee        "; 
	menuList[7].menuItem = "Tea           "; 

	menuList[0].menuPrice = 1.45; 
	menuList[1].menuPrice = 2.45; 
	menuList[2].menuPrice = 0.99; 
	menuList[3].menuPrice = 1.99; 
	menuList[4].menuPrice = 2.49; 
	menuList[5].menuPrice = 0.69; 
	menuList[6].menuPrice = 0.50; 
	menuList[7].menuPrice = 0.75; 
	
    cout << endl; 
    
    
    for (int x=0; x<3; x++) 
    { 	
        cout << " " << endl;
        int answer; 
        cout << "Enter item number: ";
        cin >> answer; 
        cout << "Select another item Y/y (Yes), N/n (No): "; 
        char selectionTwo; 
        cin >> selectionTwo; 
        placeorder[x].menuItem = menuList[answer-1].menuItem; 
        placeorder[x].menuPrice = menuList[answer-1].menuPrice; 
   } 
} 
 
void printCheck(menuItemType printorder[]) 
{ 
	const double taxRate = 0.05; 
	int x = 0;
	double amtDue = 0;
	double tax = 0; 
	
	cout << endl;
	cout << endl;
	cout << endl;

 
	cout << "Welcome to Johnny's Restaurant" << endl;  
	cout << endl;

	for (x=0; x<3; x++) 
	{ 
	    cout.precision(3);
	    cout << showpoint;
	    tax += (printorder[x].menuPrice) * taxRate;
	    cout << printorder[x].menuItem << setw(13) << "$ " << printorder[x].menuPrice << endl; 
	}

	cout.precision(2);
	cout << showpoint;
	cout<<"Tax                      $ " << tax << endl; 
	cout.precision(2);
	amtDue += (printorder[x].menuPrice) + tax;
	cout << showpoint;
	cout<<"Amount Due               $ " << amtDue << endl;
}

Line 37 - What is the purpose of this line? It doesn't hurt anything, but has no effect.

Lines 39: An else block shouldn't have any condition. Replace this line with "else". If you want a condition, use "else if". Also, you don't want the semicolon at the end of the line even if it is an "else if" statement.

Lines 40 - 41 - There is nothing these brackets. Lines 39 - 41 have no effect on your program.

Lines 83 - 94 - I'm supposed to be able to make eight orders, but the program goes through the loop only three times. Also, how do I get out of the loop if I want to stop ordering?

Lines 89 - 91 You ask whether I want to order again and read my response into a variable, but the variable is never used.

Line 112 - You are again assuming that there are exactly three orders, which may not be the case after lines 83 - 94 are changed.

Line 124 - How many times do you want this line to execute? Currently it will only execute once. If you want it to execute more than once, it needs to be in a loop.

Thanks for the advice I will use to revise my program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.