Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can Someone Please help me with this C++ homework problem? I have to make a simple pizza ordering program in C++. Thank you! I tried

Can Someone Please help me with this C++ homework problem? I have to make a simple pizza ordering program in C++. Thank you! I tried to keep this as organized as possible.

OVERVIEW: You are going to create a simple Pizza ordering program. There are three things that can happen in this ordering program. A pizza can be: Ordered, Delivered, Finish (the day that is all remaining orders are delivered).

This is what the output should look like (and there are pictures at the end):

stdout:

Enter 1 for a new order

Enter 2 to deliver an order

Enter 3 to stop

Please enter your pizza size Please enter topping (enter n when finished) Please enter a topping (enter n when finished) Enter 1 for a new order

Enter 2 to deliver an order

Enter 3 to stop Please enter your pizza size Please enter a topping (enter n when finished) Enter 1 for a new order

Enter 2 to deliver an order

Enter 3 to stop

All Pizzas delivered! Thank you!

(The end of stdoutput)

(ORDER output)

Order: 12 inch - total cost $7.00

Toppings are: onion

---------------------End of Order -------------------

Order: 14 inch - total cost $8.00

Toppings are:

---------------------End of Order -------------------

(end of the ouput for the order file)

To be able to order pizzas youll need to set up the options for ordering. You will have the basic cheese pizza size and cost. Then you will have a list of toppings and the price of each topping. To make the program easier, the cost of the topping is the same no matter the size of the pizza.

After doing the set up, youll output a 3 option menu for the waitress to manage the orders. Menu item 1 is order a new pizza, item 2 is deliver a pizza, and 3 is an end of day option that will deliver any pizzas still left.

You will have an order list (a vector). When a pizza is ordered it goes at the bottom of the list. The next pizza to be delivered is always at the top of the list. When it is delivered it is printed into an orders file and then deleted from the orders list.

Thus, this program will be using 3 files (the names of the files will be from the command line) the first file is the basic pizza size and cost, the second the toppings and cost, and the 3rd is an output file that contains the orders.

THE DETAILS:

THE DATA STRUCTURES:

You will be using 2 structs and a class to do this program. They are as follows:

A struct for a basic pizza that consists of a pizza size and the cost.

A struct for a pizza topping that will consist of a topping and its cost

A class for an Order that consists of a Basic Pizza and a vector of Pizza Toppings. Furthermore, the Order class has two constructors, a 0 argument constructor and then a constructor that takes both a Basic Pizza struct and a Pizza toppings vector as parameters. The class also has get functions for the Basic Pizza and Pizza Topping vector. Note for our purposes you cant return a vector therefore the vector for the pizza topping get will have to be done by reference.

One final function is the Pizza Cost function that returns the cost of the pizza.

OTHER FUNCTIONS THAT ARE NOT A PART OF THE CLASS;

You will create an int function to do the following:

The basic pizza sizes and cost need to be read in from the first file in the command line argument then a vector of basic pizza sizes and costs will be created from that file (the input file should be opened in the main program and passed to the function)

There is a second file to read that has the pizza toppings and the cost for that topping (a string and a double). This is the second command line argument. The data from this file will be stored in a vector of type pizza toppings.

If either of the vectors have a size of 0 the program should return a -1.

THESE ARE THE FUNCTIONS FOR PROCESSING THE ORDERS:

Create a new order: This function will return a type Order (an Order class instance). You will need to pass in the two vectors that have the basic pizza sizes and toppings as parameters. The function should do the following:

Ask for the size of the pizza then check to see if that size pizza exists in the basic pizza vector. If it doesnt have the user re-enter the pizza size until you get a valid size. (you may want to write another function for that). If you get a valid pizza size - use that vector item (i.e. the index into the vector) to create the Basic Pizza part of the order (a temporary Basic Pizza variable may come in handy).

Now get the toppings. Youll be creating a temporary vector of toppings. The user should enter a topping. If the user enters an n stop topping input. See if the topping exists and add to the vector of toppings if it doest exist tell the user the topping isnt available and allow them to enter another topping.

Now that you have basic pizza info as well as a topping vector you can use them to declare a variable of type Order using the 2 parameter constructor previously defined.

Return this Order you just created.

Deliver a pizza

This function should print the first (the 0 element) order of the order vector to the output file. Youll need to pass the vector of orders as well as the open output file (the third argument from the command line arguments).

The output to the file consists of the size of the pizza, the toppings selected and the overall price of the pizza. You must use the Pizza cost class function to get the cost of the Pizza. The price of the pizza should be printed with 2 decimal places using iomanips.

Output details: Order:(2 spaces)size " inch - total cost $"cost (fixed with 2 decimal places) end of line

Toppings details tabToppings are:(1 space) (in the loop output " " then topping)

Once the output is done the order should be removed from the list. See code assessor for what the output looks like. Be careful not to try to deliver a pizza if there are no orders!! (I used 2 functions for this a function to output to the file and then a function to remove the pizza from the order list.

THE MAIN PROGRAM:

The main program should check the command line arguments, open the files, and call the function(s) to set up the vectors of basic pizza sizes and toppings.

To make this program work you will need a vector of Orders

The main program will now display a menu on the screen with 3 options:

Create a new order

Deliver a pizza

Finish the day

If the user chooses option 1

Use your create order function to return a new Order then push that order on a vector of orders (the order queue)

If the waitress chooses option 2

Make sure there is a pizza to deliver and then use your deliver pizza functions to delete it.

If the waitress chooses option 3.

The rest of the pizzas (if any) in the orders list should be delivered and then the program should end. I used the same to function(s)from option 2 but threw a loop around them for as long as there were orders (hint the size function of a vector).

(PICTURE OF EXAMPLE OF THE INPUT AND OUTPUT)

image text in transcribed image text in transcribed

All Pizzas delivered! T order order command line args basic topping order Order: 12 inch -total Toppings are: En Order: 14 inch -total Toppings are: En basic 12 6.00 14 8.00 16 10.0 topping bacon 1.00 xcheese 1.25 onion 1.00 sausage 1.50 peppers .00 mushrooms 1.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building The Data Lakehouse

Authors: Bill Inmon ,Mary Levins ,Ranjeet Srivastava

1st Edition

1634629663, 978-1634629669

More Books

Students also viewed these Databases questions

Question

=+ Are there ways that all parties can have input into the process?

Answered: 1 week ago

Question

What is business strategy?

Answered: 1 week ago

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago