Question

in c++ Write a program that stores the following data about SJDC Pizza orders in a...

in c++

Write a program that stores the following data about SJDC Pizza orders in a structure: Customer’s Name Order Number Date Order Placed Cost of Pizza The program should keep an array of 12 of these structures. Each element is for a different order. When the program runs it should ask the user to enter the data for each order. It should then show a table that lists each order’s name, order number, date order placed and pizza price. The program should also calculate and display the total points earned by the team. The total of all the orders should also be displayed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// source.cpp

// Task1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include "Queue.h"
using namespace std;

struct Date
{
   int day, month, year;
};

struct Orders
{
   string name;
   int orderNumber;
   Date orderDate;
   double cost;
};

int main()
{
   Queue<Orders> List;
   int totalOrders = 2;
   Orders Object;

   for (int i = 0; i < totalOrders; i++)
   {
       cout << "Enter Customer Name: ";
       cin >> Object.name;
       cout << "Order Number Is: " << i + 1 << endl;
       Object.orderNumber = i + 1;
       cout << "Enter Order Date:-\n";
       cout << "Day: ";
       cin >> Object.orderDate.day;
       cout << "Month: ";
       cin >> Object.orderDate.month;
       cout << "Year: ";
       cin >> Object.orderDate.year;
       cout << "Enter Order Cost: ";
       cin >> Object.cost;
       List.enque(Object);
   }
   List.display();


   return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

// queue.h

#pragma once
#include <iostream>
using namespace std;
template <typename T>
class Queue
{
   T *ptr;
   int MSize;
   int Front;
   int Rear;
   int Count;
public:
   Queue() { MSize = 100; ptr = new T[MSize]; Front = 0; Rear = 0; Count = 0; }
   Queue(int Size) { MSize = Size; ptr = new T[Size]; Front = 0; Rear = 0; Count = 0; }
   ~Queue() { delete[] this->ptr; }
   void enque(T N)
   { if (!IsFullQueue()) { ptr[Rear % MSize] = N; Rear++; Count++; } } //++Rear % MSize
   void display()
   {
       int totalPoints = 0;
       for (int i = Front; i < Rear; i++)
       {
           cout << "Customer Name: " << ptr[i % MSize].name << endl;
           cout << "Order Number is: " << ptr[i % MSize].orderNumber << endl;
           cout << "Enter Order Date (D/M/Y): " << ptr[i % MSize].orderDate.day << "/" << ptr[i % MSize].orderDate.month << "/" << ptr[i % MSize].orderDate.year << endl;
           cout << "Enter Order Cost: " << ptr[i % MSize].cost << endl << endl;
           totalPoints += ptr[i % MSize].cost;
       }
       cout << "Total Cost: " << totalPoints << endl << endl;
   }
   T deque()
   { if (!IsEmptyQueue()) { Count--; return ptr[Front++ % MSize]; } };
   bool IsFullQueue(){ return Count == MSize; /*if (Rear - Front == MSize)return true; else return false;*/ }
   bool IsEmptyQueue(){ return !Count; /*if (Rear - Front == 0)return true; else return false;*/ }
   T front() { if (!IsEmptyQueue())   return ptr[Front]; }
   T back() { if (!IsEmptyQueue())       return ptr[Rear]; }
};

for any query leave a comment here ill get back to you as soon as possible :)

PLEASE DO NOT FORGET TO LEAVE A THUMBS UP! THANKS! :)

Add a comment
Know the answer?
Add Answer to:
in c++ Write a program that stores the following data about SJDC Pizza orders in a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Football Game Scores Write a C++ program that stores the following data about a football game...

    Football Game Scores Write a C++ program that stores the following data about a football game in a structure: Field Name Description visit_team string (name of visiting team) home_score int visit_score int The program should read the number of games from a data file named “games.txt”, dynamically allocate an array of structures for the games using one structure for each game, and then read the information for each game from the same file (visiting team, home score, visiting team’s score)....

  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

  • Write a program that uses a class or structure to store the following data about a...

    Write a program that uses a class or structure to store the following data about a customer account. Name Address City, State and Zip Telephone Number Account Balance Date of Last Payment The program should use an array or vector of 10 objects. It should let the users enter data, change the contents of any element and display all the data stored in the array or vector. The program should be modular and menu driven. Validation: When the data for...

  • Need done in C++ Can not get my code to properly display output. Instructions below. The...

    Need done in C++ Can not get my code to properly display output. Instructions below. The code compiles but output is very off. Write a program that scores the following data about a soccer player in a structure:            Player’s Name            Player’s Number            Points Scored by Player      The program should keep an array of 12 of these structures. Each element is for a different player on a team. When the program runs, it should ask the user...

  • In Java Problem Description/Purpose:  Write a program that will compute and display the final score...

    In Java Problem Description/Purpose:  Write a program that will compute and display the final score of two teams in a baseball game. The number of innings in a baseball game is 9.    Your program should read the name of the teams. While the user does not enter the word done for the first team name, your program should read the second team name and then read the number of runs for each Inning for each team, calculate the...

  • I need this done in C++ Can someone help me get my code from crashing. The...

    I need this done in C++ Can someone help me get my code from crashing. The code compiles but it can be easily crashed with user input. The rubric and code below Instructions: Write a program that scores the following data about a soccer player in a structure:            Player’s Name            Player’s Number            Points Scored by Player      The program should keep an array of 12 of these structures. Each element is for a different player on a...

  • q13 c++ if answering please do not write code in paragrapth form. 13. Drink Machine Simulator...

    q13 c++ if answering please do not write code in paragrapth form. 13. Drink Machine Simulator Write a program that simulates a soft drink machine. The program should use a structure that stores the following data: Drink Name Drink Cost Number of Drinks in Machine The program should create an array of five structures. The elements should be initialized with the following data: Drink Name Cost Number in Machine Cola .75 20 Root Beer .75 20 Lemon-Lime .75 20 Grape...

  • Write a Python program that stores the data for each player on the team, and it...

    Write a Python program that stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. Questions: - Handle the exception that occurs if the program can’t find the data file. - Handle the exceptions that occur if the user enters a string where an integer is expected. - Handle the exception that occurs if the user enters zero for the number of at bats. - Thoroughly test the...

  • C++ programming language Write a program that asks the user for a file name. The file...

    C++ programming language Write a program that asks the user for a file name. The file contains a series of scores(integers), each written on a separate line. The program should read the contents of the file into an array and then display the following content: 1) The scores in rows of 10 scores and in sorted in descending order. 2) The lowest score in the array 3) The highest score in the array 4) The total number of scores in...

  • Create an order entry screen program in C# to give a total for an individual pizza...

    Create an order entry screen program in C# to give a total for an individual pizza order. The Pizza order should have radio buttons for small $7, medium $9, and large $12 choices for the pizza. There should be a checkbox for drink (where a drink is $2 added if it is checked and nothing added if it is not checked. Include a textbox for the customer’s name. Have a button to calculate the subtotal (pizza choice and whether there...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT