SlideShare a Scribd company logo
1 of 11
#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 &r, int &c , string &k, bool& l, string
&d)
{
reportingMark =r;
carNumber = c;
kind = k;
loaded = l;
destination = d;
}
};
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 (reportingMark, carNumber, kind, loaded, destination);
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!"< }
}
while (choice != "true" && choice != "false");
if(loaded==true)
{
cout<<"Entre the destination:";
cin.ignore();
getline(cin,destination);
}
if(loaded ==false)
{
destination = "NONE";
}
}
this is lab2 and the qustion is:
Use the same format for problem and function headings as
assignment A.
Problem 3.1
Copy the solution from problem 2.2
Make the following additions and changes:
1. Arrange the functions in the order:
* main
* output
* setUp (was setUpCar)
* input
2. Change the output function so it is a member function of the
class Car.
3. Change the name of the setUpCar function to setUp and make
it a
member function of the class Car, with five parameters
specified as
constant reference parameters.
4. Make all the data in the Car class private and make the
member
functions public.
5. Do NOT make the input function a member function.
6. Change the parameters of the input function to five reference
parameters corresponding to the five fields in the class.
7. In main define five variables. Pass these variables to the
input
function so the input function can set their values.
8. In main define a Car object. This time the Car object will be
in the
stack for main, rather than in the heap. Name this object car1.
9. In main call the setUp function and pass the five variables,
rather
than calling it from the input function.
10. In main call the output function.
11. Test the program with the same data as was used in
assignment B.
Solution
Try the below changed code...it may help you to an extent
#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 setUp(const string &r, const int &c , const string &k,
const bool &l, const string &d);
void output(string &reportingMark, int &carNumber, string&
kind, bool &loaded, string &destination);
}; //class ends
void input(string &reportingMark, int &carNumber, string&
kind, bool &loaded,string choice, 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 car1;
car1.setUp(reportingMark,carNumber, kind, loaded,
destination);
car1.output (reportingMark, carNumber, kind, loaded,
destination);
return 0;
}
/* ************* Function output ************
show all results of the program
******************************************* */
void Car :: 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 SetUp **************
Sets the data
****************************************** */
void Car :: setUp(const string &r,const int &c ,const string
&k,const bool& l,const string &d)
{
reportingMark =r;
carNumber = c;
kind = k;
loaded = l;
destination = d;
}
/* ************ 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<<"Enter the destination:";
cin.ignore();
getline(cin,destination);
}
if(loaded ==false)
{
destination = "NONE";
}
}

More Related Content

Similar to #include iostream #include string#includeiomanip using.docx

publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfANGELMARKETINGJAIPUR
 
TypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason HaffeyTypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason HaffeyRalph Johnson
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ AdvancedVivek Das
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfajantha11
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...kushwahashivam413
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdfvinodagrawal6699
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
chapter-6 slide.pptx
chapter-6 slide.pptxchapter-6 slide.pptx
chapter-6 slide.pptxcricketreview
 
Automobile.javapublic class Automobile {    Declaring instan.pdf
Automobile.javapublic class Automobile {    Declaring instan.pdfAutomobile.javapublic class Automobile {    Declaring instan.pdf
Automobile.javapublic class Automobile {    Declaring instan.pdfanitasahani11
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfjyothimuppasani1
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfarsmobiles
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...RSathyaPriyaCSEKIOT
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar B Kute
 
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfCountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfAggarwalelectronic18
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212Mahmoud Samir Fayed
 

Similar to #include iostream #include string#includeiomanip using.docx (20)

publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdfpublicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
publicclass VehicleParser {publicstatic Vehicle parseStringToVehic.pdf
 
TypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason HaffeyTypeScript Presentation - Jason Haffey
TypeScript Presentation - Jason Haffey
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Functions
FunctionsFunctions
Functions
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ Advanced
 
C#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdfC#i need help creating the instance of stream reader to read from .pdf
C#i need help creating the instance of stream reader to read from .pdf
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdfONLY EDIT  CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
ONLY EDIT CapacityOptimizer.java, Simulator.java, and TriangularD.pdf
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
chapter-6 slide.pptx
chapter-6 slide.pptxchapter-6 slide.pptx
chapter-6 slide.pptx
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
Automobile.javapublic class Automobile {    Declaring instan.pdf
Automobile.javapublic class Automobile {    Declaring instan.pdfAutomobile.javapublic class Automobile {    Declaring instan.pdf
Automobile.javapublic class Automobile {    Declaring instan.pdf
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
 
Goal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdfGoal The goal of this assignment is to help students understand the.pdf
Goal The goal of this assignment is to help students understand the.pdf
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdfCountryData.cppEDIT THIS ONE#include fstream #include str.pdf
CountryData.cppEDIT THIS ONE#include fstream #include str.pdf
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
 

More from ajoy21

Please complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxajoy21
 
Please cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxPlease cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxajoy21
 
Please choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxPlease choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxajoy21
 
Please check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxajoy21
 
Please answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxPlease answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxajoy21
 
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxPlease attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxajoy21
 
Please answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxPlease answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxajoy21
 
Please answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxPlease answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxajoy21
 
Please answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxPlease answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxajoy21
 
Please answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxPlease answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxajoy21
 
Please answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxPlease answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxajoy21
 
Please answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxPlease answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxajoy21
 
Please answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxPlease answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxajoy21
 
Please answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxPlease answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxajoy21
 
Please answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxPlease answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxajoy21
 
Please answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxPlease answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxajoy21
 
Please answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxPlease answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxajoy21
 
Please answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxPlease answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxajoy21
 
Please answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxPlease answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxajoy21
 
Please answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxPlease answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxajoy21
 

More from ajoy21 (20)

Please complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docxPlease complete the assignment listed below.Define and explain, us.docx
Please complete the assignment listed below.Define and explain, us.docx
 
Please cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docxPlease cite sources for each question. Do not use the same sources f.docx
Please cite sources for each question. Do not use the same sources f.docx
 
Please choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docxPlease choose one of the following questions to answer for this week.docx
Please choose one of the following questions to answer for this week.docx
 
Please check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docxPlease check the attachment for my paper.Please add citations to a.docx
Please check the attachment for my paper.Please add citations to a.docx
 
Please answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docxPlease answer to this discussion post. No less than 150 words. Refer.docx
Please answer to this discussion post. No less than 150 words. Refer.docx
 
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docxPlease attach Non-nursing theorist summaries.JigsawExecutive .docx
Please attach Non-nursing theorist summaries.JigsawExecutive .docx
 
Please answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docxPlease answer the question .There is no work count. PLEASE NUMBER .docx
Please answer the question .There is no work count. PLEASE NUMBER .docx
 
Please answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docxPlease answer the following questions. Please cite your references..docx
Please answer the following questions. Please cite your references..docx
 
Please answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docxPlease answer the following questions.1.      1.  Are you or.docx
Please answer the following questions.1.      1.  Are you or.docx
 
Please answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docxPlease answer the following question with 200-300 words.Q. Discu.docx
Please answer the following question with 200-300 words.Q. Discu.docx
 
Please answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docxPlease answer the following question Why do you think the US ha.docx
Please answer the following question Why do you think the US ha.docx
 
Please answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docxPlease answer the following questions. Define tunneling in the V.docx
Please answer the following questions. Define tunneling in the V.docx
 
Please answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docxPlease answer the following questions1. How can you stimulate the.docx
Please answer the following questions1. How can you stimulate the.docx
 
Please answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docxPlease answer the following questions very deeply and presicely .docx
Please answer the following questions very deeply and presicely .docx
 
Please answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docxPlease answer the following questions in an informal 1 ½ - 2-page es.docx
Please answer the following questions in an informal 1 ½ - 2-page es.docx
 
Please answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docxPlease answer the following questions in a response of 150 to 200 wo.docx
Please answer the following questions in a response of 150 to 200 wo.docx
 
Please answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docxPlease answer these questions regarding the (TILA) Truth in Lending .docx
Please answer these questions regarding the (TILA) Truth in Lending .docx
 
Please answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docxPlease answer the following question pertaining to psychology. Inc.docx
Please answer the following question pertaining to psychology. Inc.docx
 
Please answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docxPlease answer the following questions in a response of 250 to 300 .docx
Please answer the following questions in a response of 250 to 300 .docx
 
Please answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docxPlease answer the three questions completly. I have attached the que.docx
Please answer the three questions completly. I have attached the que.docx
 

Recently uploaded

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 

Recently uploaded (20)

Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 

#include iostream #include string#includeiomanip using.docx

  • 1. #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 &r, int &c , string &k, bool& l, string &d) { reportingMark =r; carNumber = c; kind = k; loaded = l;
  • 2. destination = d; } }; 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 (reportingMark, carNumber, kind, loaded, destination); 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) {
  • 3. 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: ";
  • 4. 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!"< } } while (choice != "true" && choice != "false"); if(loaded==true) { cout<<"Entre the destination:"; cin.ignore(); getline(cin,destination); } if(loaded ==false) { destination = "NONE"; } } this is lab2 and the qustion is: Use the same format for problem and function headings as assignment A.
  • 5. Problem 3.1 Copy the solution from problem 2.2 Make the following additions and changes: 1. Arrange the functions in the order: * main * output * setUp (was setUpCar) * input 2. Change the output function so it is a member function of the class Car. 3. Change the name of the setUpCar function to setUp and make it a member function of the class Car, with five parameters specified as constant reference parameters. 4. Make all the data in the Car class private and make the member functions public. 5. Do NOT make the input function a member function. 6. Change the parameters of the input function to five reference parameters corresponding to the five fields in the class. 7. In main define five variables. Pass these variables to the input function so the input function can set their values. 8. In main define a Car object. This time the Car object will be in the stack for main, rather than in the heap. Name this object car1. 9. In main call the setUp function and pass the five variables, rather than calling it from the input function. 10. In main call the output function. 11. Test the program with the same data as was used in assignment B.
  • 6. Solution Try the below changed code...it may help you to an extent #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()
  • 7. { reportingMark = ""; carNumber = 0; kind = "Others"; loaded = 0; destination = "NONE"; } ~Car(){} void setUp(const string &r, const int &c , const string &k, const bool &l, const string &d); void output(string &reportingMark, int &carNumber, string& kind, bool &loaded, string &destination); }; //class ends void input(string &reportingMark, int &carNumber, string& kind, bool &loaded,string choice, string& destination); //*********** Main ************** int main() { string reportingMark; int carNumber; string kind; string choice; bool loaded; string destination; input(reportingMark, carNumber, kind, loaded, choice,
  • 8. destination); Car car1; car1.setUp(reportingMark,carNumber, kind, loaded, destination); car1.output (reportingMark, carNumber, kind, loaded, destination); return 0; } /* ************* Function output ************ show all results of the program ******************************************* */ void Car :: 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;
  • 9. 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 SetUp ************** Sets the data ****************************************** */ void Car :: setUp(const string &r,const int &c ,const string &k,const bool& l,const string &d) { reportingMark =r; carNumber = c; kind = k; loaded = l; destination = d; } /* ************ Function Input ************** Collect the data ****************************************** */
  • 10. 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") {
  • 11. loaded = true; } else if (choice == "false") { loaded = false; } else { cout<<"error!"<< endl; } }while (choice != "true" && choice != "false"); if(loaded==true) { cout<<"Enter the destination:"; cin.ignore(); getline(cin,destination); } if(loaded ==false) { destination = "NONE"; } }