This is for my c++ class and I would really appreciate the help, Thank you!
Complete the definitions of the functions for the ConcessionStand class in the ConcessionStand.cpp file. The class definition and function prototypes are in the provided ConcessionStand.h header file. A testing program is in the provided main.cpp file. You don’t need to change anything in ConcessionStand.h or main.cpp, unless you want to play with different options in the main.cpp program.
___________________
Main.cpp
____________________
#include "ConcessionStand.h" #include <iostream> using namespace std; int main() { ConcessionStand standA{"Pizzeria"}; standA.addItemToMenu("Cheese", 3.50, 1); standA.addItemToMenu("Veggie", 4.50, 2); standA.addItemToMenu("Pepperoni", 4.50, 3); standA.addItemToMenu("Mushroom", 4.50, 1); standA.displayMenu(); standA.sellMenuItem(1); standA.sellMenuItem(4); standA.displayMenu(); standA.sellMenuItem(1); if (!standA.printInventoryToFile()) cout << "\nCould not print inventory to file!\n";
_________________
ConcessionStand.cpp
_________________
#include "ConcessionStand.h" #include <iostream> #include <iomanip> // std::setw(), std::setprecision(), std::fixed, std::left #include <fstream> #include <string> #include <vector> // constructors // change information // get information
____________________
ConcessionStand.h
____________________
#include <string> #include <vector> #ifndef CONCESSION_STAND #define CONCESSION_STAND class ConcessionStand { public: ConcessionStand(){}; ConcessionStand(std::string); // name of stand void displayMenu() const; bool printInventoryToFile() const; void addItemToMenu(std::string, double, unsigned int); void sellMenuItem(unsigned int); private: std::vector<std::string> products; std::vector<double> prices; std::vector<unsigned int> quantity; std::string standName; }; #endif
//please get back to me in case of any issues
//always happy to help
//thanks
#include "ConcessionStand.h"
#include <iostream>
#include <iomanip> // std::setw(), std::setprecision(),
std::fixed, std::left
#include <fstream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
// constructors
// change information
// get information
ConcessionStand::ConcessionStand(std::string standName){
this->standName = standName;
}
void ConcessionStand::displayMenu() const{
cout<<"--------------MENU-----------------"<<endl;
vector<double>::const_iterator pricesIt =
this->prices.begin();
vector<unsigned int>::const_iterator quantityIt
= this->quantity.begin();
for(vector<string>::const_iterator it =
this->products.begin(); it != this->products.end();
it++){
cout<<*it<<" -------
"<<*pricesIt<<" -------
"<<*quantityIt<<endl;
pricesIt++;
quantityIt++;
}
}
void ConcessionStand::addItemToMenu(std::string item,double
price,unsigned int quantity){
this->products.push_back(item);
this->prices.push_back(price);
this->quantity.push_back(quantity);
cout<<"new product added !!!"<<endl;
}
void ConcessionStand::sellMenuItem(unsigned int item){
item = item -1;
if(item>this->products.size()){
cout<<"ERROR !!!! , No such
item"<<endl;
return;
}
if(this->quantity[item] == 0){
cout<<"ERROR !!!! , not
enough left"<<endl;
return;
}
else if(this->quantity[item] == 1){
this->products.erase(this->products.begin()+item);
this->prices.erase(this->prices.begin()+item);
this->quantity.erase(this->quantity.begin()+item);
cout<<"item
sold!!!!"<<endl;
}
else{
this->quantity[item]=this->quantity[item]-1;
cout<<"item
sold!!!!"<<endl;
}
}
bool ConcessionStand::printInventoryToFile() const{
FILE* ptr;
ptr=fopen("Inventory.text","w");
if(ptr == NULL){
cout<<"could not open
file"<<endl;
return false;
}
for(int i=0;i<this->products.size();i++){
int a=this->quantity[i];
double p=this->prices[i];
std::string
str=this->products[i];
const char* cstr=str.data();
fprintf(ptr,"%s %u
%d\n",cstr,p,a);
}
return true;
}
This is for my c++ class and I would really appreciate the help, Thank you! Complete...
This is for my c++ class and im stuck. Complete the Multiplex.cpp file with definitions for a function and three overloaded operators. You don't need to change anything in the Multiplex.h file or the main.cpp, though if you want to change the names of the movies or concession stands set up in main, that's fine. Project Description: A Multiplex is a complex with multiple movie theater screens and a variety of concession stands. It includes two vectors: screenings holds pointers...
Please help fix my code C++, I get 2 errors when running. The code should be able to open this file: labdata.txt Pallet PAG PAG45982IB 737 4978 OAK Container AYF AYF23409AA 737 2209 LAS Container AAA AAA89023DL 737 5932 DFW Here is my code: #include <iostream> #include <string> #include <fstream> #include <vector> #include <cstdlib> #include <iomanip> using namespace std; const int MAXLOAD737 = 46000; const int MAXLOAD767 = 116000; class Cargo { protected: string uldtype; string abbreviation; string uldid; int...
test.txtLab7.pdfHeres the main.cpp:#include "Widget.h"#include <vector>#include <iostream>#include <string>#include <iomanip>#include <fstream>using std::ifstream;using std::cout;using std::cin;using std::endl;using std::vector;using std::string;using std::setprecision;using std::setw;bool getWidget(ifstream& is, Widget& widget){ string name; int count; float unitCost; if (is.eof()) { return false; } is >> count; is >> unitCost; if (is.fail()) { return false; } is.ignore(); if (!getline(is, name)) { return false; } widget.setName(name); widget.setCount(count); widget.setUnitCost(unitCost); return true;}// place the definitions for other functions here// definition for function mainint main(){ // Declare the variables for main here // Prompt the...
C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the Facility.cpp file and the other files are included in case they're needed for understanding. I was able to complete the mayday.cpp file but am stuck on Facility. The following link contains a tar file with the files provided by the professor. Thank you so much in advanced! http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/ Closer.h: #ifndef CLOSER_H #define CLOSER_H #include <string> #include "gcdistance.h" struct Closer { const double latitude, longitude;...
I need to add something to this C++ program.Additionally I want it to remove 10 words from the printing list (Ancient,Europe,Asia,America,North,South,West ,East,Arctica,Greenland) #include <iostream> #include <map> #include <string> #include <cctype> #include <fstream> #include <iomanip> using namespace std; void addWord(map<std::string,int> &words,string s); void readFile(string infile,map<std::string,int> &words); void display(map<std::string,int> words); int main() { // Declaring variables std::map<std::string,int> words; //defines an input stream for the data file ifstream dataIn; string infile; cout<<"Please enter a File Name :"; cin>>infile; readFile(infile,words);...
I need to make a few changes to this C++ program,first of all it should read the file from the computer without asking the user for the name of it.The name of the file is MichaelJordan.dat, second of all it should print ,3 highest frequencies are: 3 words that occure the most.everything else is good. #include <iostream> #include <map> #include <string> #include <cctype> #include <fstream> #include <iomanip> using namespace std; void addWord(map<std::string,int> &words,string s); void readFile(string infile,map<std::string,int> &words); void display(map<std::string,int>...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include <string> #include <iomanip> using namespace std; struct Drink { string name; double cost; int noOfDrinks; }; void displayMenu(Drink drinks[], int n); int main() { const int size = 5; Drink drinks[size] = { {"Cola", 0.65, 2}, {"Root Beer", 0.70, 1}, {"Grape Soda", 0.75, 5}, {"Lemon-Lime", 0.85, 20}, {"Water", 0.90, 20} }; cout <<...
This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...
The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is wrong with the code written. I get errors about stockSym being private and some others after that.This was written in the Dev C++ software. Can someone help me figure out what is wrong with the code with notes of what was wrong to correct it? #include <cstdlib> #include <iostream> #include <iomanip> #include <fstream> #include <cassert> #include <string> using namespace std; template <class stockType> class...