0% found this document useful (0 votes)
6 views8 pages

Pizza Order Management System Code

The document contains a C++ program that implements a pizza order management system using a circular queue structure. It allows users to accept pizza orders, deliver them, and display pending orders with a simple menu interface. The queue has a fixed size of 5 and includes functions to check if it is full or empty, as well as to handle order processing.

Uploaded by

Rohit Phalke
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

Pizza Order Management System Code

The document contains a C++ program that implements a pizza order management system using a circular queue structure. It allows users to accept pizza orders, deliver them, and display pending orders with a simple menu interface. The queue has a fixed size of 5 and includes functions to check if it is full or empty, as well as to handle order processing.

Uploaded by

Rohit Phalke
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ASSIGNMENT 13

#include <iostream>

using namespace std;

#define SIZE 5

// Struct to represent the pizza queue

struct PizzaQueue {

int orders[SIZE];

int front;

int rear;

};

// Function to initialize the queue

void initializeQueue(PizzaQueue &pq) {

[Link] = -1;

[Link] = -1;

// Function to check if the queue is full

bool isFull(PizzaQueue &pq) {

return (([Link] == 0 && [Link] == SIZE - 1) || ([Link] == [Link] + 1));

// Function to check if the queue is empty

bool isEmpty(PizzaQueue &pq) {

return ([Link] == -1);

// Function to accept a new order


void acceptOrder(PizzaQueue &pq, int order) {

if (isFull(pq)) {

cout << "Sorry, the queue is full!" << endl;

return;

if (isEmpty(pq)) { // If the queue is empty, initialize front and rear

[Link] = 0;

[Link] = 0;

} else { // Increment rear in a circular manner

[Link] = ([Link] + 1) % SIZE;

[Link][[Link]] = order;

cout << "Order accepted: Pizza type " << order << endl;

// Function to deliver orders

void deliverOrders(PizzaQueue &pq, int numOrders) {

if (isEmpty(pq)) {

cout << "No pending orders!" << endl;

return;

cout << "Delivering the following orders: " << endl;

for (int i = 0; i < numOrders; i++) {

if (isEmpty(pq)) {

cout << "\nNo more orders to deliver!" << endl;

break;

}
int deliveredOrder = [Link][[Link]];

cout << "Pizza type " << deliveredOrder << endl;

// Remove the delivered order from the queue

if ([Link] == [Link]) { // If there's only one order

[Link] = -1;

[Link] = -1;

} else { // Increment front in a circular manner

[Link] = ([Link] + 1) % SIZE;

cout << "Total amount to pay: " << numOrders * 100 << " units" << endl;

// Function to display pending orders

void displayOrders(PizzaQueue &pq) {

if (isEmpty(pq)) {

cout << "No pending orders!" << endl;

return;

cout << "Pending orders: ";

int temp = [Link];

while (true) {

cout << [Link][temp] << " ";

if (temp == [Link]) {

break;

temp = (temp + 1) % SIZE;

cout << endl;


}

int main() {

PizzaQueue pq;

initializeQueue(pq);

int choice, pizzaType, numOrders;

do {

cout << "\n\n______Welcome To MMCOE Pizza house______" << endl;

cout << "1. Accept Order" << endl;

cout << "2. Deliver Orders" << endl;

cout << "3. Display Pending Orders" << endl;

cout << "4. Exit" << endl;

cout << "Enter your choice: ";

cin >> choice;

switch (choice) {

case 1:

cout << "\n____MENU___" << endl;

cout << "[Link] Pizza" << endl;

cout << "2. golden corn Pizza" << endl;

cout << "[Link] Pizza" << endl;

cout << "Which pizza do you want? Enter the respective number: ";

cin >> pizzaType;

acceptOrder(pq, pizzaType);

break;

case 2:

cout << "\nHow many pizzas do you want to deliver? ";

cin >> numOrders;

deliverOrders(pq, numOrders);
break;

case 3:

displayOrders(pq);

break;

case 4:

cout << "Exiting the program. Thank you for visiting!" << endl;

break;

default:

cout << "Invalid choice, please try again!" << endl;

} while (choice != 4);

return 0;}

You might also like