Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use C++ only!! ------------------------------------------------------------------------------------------------------ #include #include #include using namespace std; class Item { public: string uld; string abbreviation; string uldid; int aircraft; double weight;

Please use C++ only!!

image text in transcribed

------------------------------------------------------------------------------------------------------

#include #include #include using namespace std; class Item { public: string uld; string abbreviation; string uldid; int aircraft; double weight; string destination; Item (){}

Item(string iuld, string iabbreviation, string iuldid, int iaircraft, double iweight , string idestination){ uld=iuld; abbreviation=iabbreviation; uldid=iuldid; aircraft=iaircraft; weight=iweight; destination=idestination; } Item(Item & i){ uld = i.uld; abbreviation= i.abbreviation; uldid=i.uldid; aircraft=i.aircraft; weight=i.weight; destination=i.destination; } void print(){ cout

} friend bool operator ==(Item &,Item &); friend void kilotopound(Item ); }; bool operator ==(Item &a, Item &b){ if((a.abbreviation == b.abbreviation) && (a.uldid == b.uldid)){ return true; } else{ return false; } } void input(){ ifstream inputFile; string iuld; string iabbreviation; string iuldid; int iaircraft; double iweight ; string idestination;

inputFile.open("cardata4.txt"); if(!inputFile){ cout > iuld >> iabbreviation >> iuldid >> iaircraft >> iweight >> idestination; Item temp(iuld, iabbreviation, iuldid, iaircraft, iweight, idestination); temp.print(); } } inputFile.close(); } int main() { input(); return 0; } ------------------------------------------------------------------------------------------------------

My data is public, needs to be private.

Please change public to private Data.

Lab 4.2 Using the code from lab 4.1, add the ability to read from a file... Modify the input function: * Move the input function out of the Cargo class to just below the end of the Cargo class. * At the bottom of the input function, declare a Cargo object named. temp using the constructor that takes the six parameters.. * Use the Cargo output function to print the Cargo object. * Call the input function from the main function with no arguments. Remove the rest of the code. from main. 3. Create a file and use it for input. This is good because you will be using the input many times... * Create a file named cardata4.txt (or use the one provided), containing the following three lines of data. .. If you create your own, make sure to follow the format. below: Pallet PAG PAG459821B 737 4978 OAK. Container AYE AYF23409AA 737 2209 LAS. Container AAA AAA89023DL 737 5932 DFW.. All weights are in pounds, don't worry about kilograms. You may. comment out that code... * In the input function, declare an object of type ifstream named inputFile, which we will use to read from the file... * At the beginning of the code for the input function, open the file. If the open fails, send a message to stderr and exit the. program... In all the reads within the input function, remove the user. prompt and read from the input file object, rather than reading. from the stdin object. * Hint: We need to use getline when reading the strings. using >> skips leading white space before reading the data... getline does not skip this leading whitespace. So, before using getline use the following code:.. while(inputFile.peek() == ""). inputFile.get(); peek looks at the next character you are about to read. If it is. a space, get is used to read the space character, to get it out. of the way. Your output will then be much neater... Use a loop to read each line from the file. To do this use a.. while loop including all the reading in the input function, as. well building and output of the Car

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What are the workforce planning challenges at BCC?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago