#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
/* ********* Class Car *************
********************************* */
class Car
{
private:
string reportingMark;
int carNumber;
string kind;
bool loaded;
string choice;
string destination;
public:
Car()
{
reportingMark = "";
carNumber = 0;
kind = "Others";
loaded = 0;
destination = "NONE";
}
~Car()
{
}
void setUpCar(string &reportingMark, int &carNumber, string
&kind, bool &loaded, string &destination);
};
void input(string &reportingMark, int &carNumber, string
&kind, bool &loaded,string choice, string
&destination);
void output(string &reportingMark, int &carNumber, string
&kind, bool &loaded, string &destination);
//*********** Main **************
int main()
{
string reportingMark;
int carNumber;
string kind;
string choice;
bool loaded;
string destination;
input (reportingMark, carNumber, kind, loaded, choice,
destination);
Car *cPtr;
cPtr = setUpCar(reportingMark,carNumber, kind, loaded,
destination);
output (cPtr);
delete cPtr;
return 0;
}
/* ************* Function output ************
show all results of the program
******************************************* */
void output(string &reportingMark, int &carNumber, string
&kind, bool &loaded, string &destination)
{
string strLoaded;
if (loaded==true)
{
strLoaded = "TRUE";
}
else
{
strLoaded = "FALSE";
}
cout << fixed << left << setw(18) <<
"Reporting Mark" << reportingMark << endl;
cout << fixed << left << setw(18) << "Car
Number" << carNumber << endl;
cout << fixed << left << setw(18) << "Kind"
<< kind << endl;
cout << fixed << left << setw(18) <<
"Loaded" << strLoaded << endl;
cout << fixed << left << setw(18) <<
"Destination" << destination << endl;
cout << endl;
}
/* ************ Function Input **************
Collect the data
****************************************** */
void input(string &reportingMark, int &carNumber, string
&kind, bool &loaded,string choice, string
&destination)
{
int len;
cout<< "Enter reportingMark with 5 or less upper case
characters: ";
getline(cin, reportingMark);
len= reportingMark.length();
while (len > 5)
{
cout<< "invalid! Enter reportingMark with 5 or less upper
case characters: ";
getline(cin, reportingMark);
len= reportingMark.length();
}
cout<< "Enter Car Number: ";
cin>> carNumber;
cout << "Enter kind of car: ";
cin>> kind;
do
{
cout<<"Enter the loaded only true or false:";
cin>>choice;
if (choice == "true")
{
loaded = true;
}
else if (choice == "false")
{
loaded = false;
}
else
{
cout<<"error!"<<endl;
}
}
while (choice != "true" && choice != "false");
if(loaded==true)
{
cout<<"Entre the destination:";
cin.ignore();
getline(cin,destination);
}
if(loaded ==false)
{
destination = "NONE";
}
}
/* ******************** setUpCar ********************
creates an object using a constructor that takes the reference
parameters
pointer to the object c1 returned.
*/
Car* setUpCar(string &reportingMark, int &carNumber, string
&kind, bool &loaded, string &destination)
{/
Car *c1 = new Car (reportingMark, carNumber, kind, loaded,
destination);
return c1;
}; // end setUpCar
this code is not working I think it is problem with setUpCar function...
Help me...
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
#include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car {...
Need help doing program In bold is problem E2 #include<iostream> #include<string> #include<vector> using namespace std; //Car class //Defined enum here enum Kind{business,maintenance,other,box,tank,flat,otherFreight,chair,seater,otherPassenger}; //Defined array of strings string KIND_ARRAY[]={"business","maintenance","other,box","tank,flat","otherFreight","chair","seater","otherPassenger"}; class Car { private: string reportingMark; int carNumber; Kind kind; //changed to Kind bool loaded; string destination; public: //Defined setKind function Kind setKind(string knd) { for(int i=0;i<8;i++) //repeat upto 8 kinds { if(knd.compare(KIND_ARRAY[i])==0) //if matched in Array kind=(Kind)i; //setup that kind } return kind; } //Default constructor Car() { } //Parameterized constructor...
#include <iostream> #include <string> #include <cstring> using namespace std; class Node{ private: int data; Node* nextNodePtr; public: Node(){} void setData(int d){ data = d; } int getData(){ return data; } void setNextNodePtr(Node* nodePtr){ nextNodePtr = nodePtr; } ...
CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...
#include <iostream> #include <iomanip> #include <vector> #include <string> using namespace std; struct menuItemType { string menuItem; double menuPrice; }; void getData(menuItemType menuList[]); void showMenu(menuItemType menuList[], int x); void printCheck(menuItemType menuList[], int menuOrder[], int x); int main() { const int menuItems = 8; menuItemType menuList[menuItems]; int menuOrder[menuItems] = {0}; int orderChoice = 0; bool ordering = true; int count = 0; getData(menuList); showMenu(menuList, menuItems); while(ordering) { cout << "Enter the number for the item you would\n" << "like to order, or...
#include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; struct transition{ // transition structure char start_state, to_state; char symbol_read; }; void read_DFA(struct transition *t, char *f, int &final_states, int &transitions){ int i, j, count = 0; ifstream dfa_file; string line; stringstream ss; dfa_file.open("dfa.txt"); getline(dfa_file, line); // reading final states for(i = 0; i < line.length(); i++){ if(line[i] >= '0' && line[i] <= '9') f[count++] = line[i]; } final_states = count; // total number of final states // reading...
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"...
#include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital, double stArea, int yAdm, int oAdm) { stateName = sName; stateCapital = sCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission; } void stateData::getStateInfo(string& sName, string& sCapital, double& stArea, int& yAdm, int& oAdm) { sName = stateName; sCapital = stateCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission; } string stateData::getStateName() { return stateName;...
Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() { string first, last, job; double hours, wages, net, gross, tax, taxrate = .40; double oPay, oHours; int deductions; // input section cout << "Enter First Name: "; cin >> first; cout << "Enter Last Name: "; cin >> last; cin.ignore(); cout << "Enter Job Title: "; getline(cin, job); cout << "Enter Hours Worked:...
Write a psuedocode for this program. #include <iostream> using namespace std; string message; string mappedKey; void messageAndKey(){ string msg; cout << "Enter message: "; getline(cin, msg); cin.ignore(); //message to uppercase for(int i = 0; i < msg.length(); i++){ msg[i] = toupper(msg[i]); } string key; cout << "Enter key: "; getline(cin, key); cin.ignore(); //key to uppercase for(int i = 0; i < key.length(); i++){ key[i] = toupper(key[i]); } //mapping key to message string keyMap = ""; for (int i = 0,j...
#include "stdafx.h" #include <iostream> using namespace std; class dateType { private: int dmonth; int dday; int dyear; public: void setdate (int month, int day, int year); int getday()const; int getmonth()const; int getyear()const; int printdate()const; bool isleapyear(int year); dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) { int numofdays; if (year<=2008) { dyear=year;...