Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following is my C++ code. I'm not sure why it's printing a third inventory record label as displayed below. Could anyone help me solve

The following is my C++ code. I'm not sure why it's printing a third inventory record label as displayed below. Could anyone help me solve this? It shouldn't be printing the third label.

#include #include #include #include using namespace std;

// Date definition struct Date{ short day; short month; int year; };

// Inventory declaration struct Inventory{ string manufacturer; string processor; int ram; int disk_size; double cost; string location; Date date_acquired; string asset_tag; };

// read_record declaration Inventory read_record(ifstream &inFile);

// display_record declaration void display_record(const Inventory &inv);

// Main function int main(){ ifstream inFile; inFile.open("input.txt"); if(inFile.fail()){ cout

Inventory record;

while(!inFile.eof()){ record = read_record(inFile); display_record(record); }

inFile.close();

return 0; }

// read_record definition to read the files in Inventory read_record(ifstream &inFile){ Inventory rec; getline(inFile, rec.manufacturer); getline(inFile, rec.processor); inFile >> rec.ram >> rec.disk_size >> rec.cost; inFile.get(); getline(inFile, rec.location); inFile >> rec.date_acquired.month >> rec.date_acquired.day >> rec.date_acquired.year; inFile >> rec.asset_tag; inFile.get(); return rec; }

// display_record definition to re-arrange the output of the record labels void display_record(const Inventory &inv){ cout

image text in transcribed

My input.txt file looks like this:

Dell Core i7 8700 (3.2 GHz) 16 256 1087.99 KM256 2 17 2017 20191231-PC-021 HP Compaq Ryzen 2400GE (3.20 GHz) 8 1024 459.00 KM128 10 31 2019 20191215-PC-045

- - - - - - - - - - - - - - - -- ------ -- Asset Tag: Acquired: Cost: Location: Manufacturer: CPU: RAM: Disk: 20191231-PC-021 02/17/2017 $1087.99 KM256 Dell Core i7 8700 (3.2 GHz) 16 GB 256 GB - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ------------ --------- --------- ------ Asset Tag: 20191215-PC-045 Acquired: 10/31/2019 Cost: $459.00 Location: KM128 Manufacturer: HP Compaq CPU: Ryzen 2400GE (3.20 GHz) RAM: 8 GB Disk: 1024 GB - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---------- --------- --------- ------ 10/31/2019 $459.00 -- Asset Tag: Acquired: Cost: Location: Manufacturer: CPU: RAM: Disk: 8 GB 1024 GB -- ----- Process exited after 0.2501 seconds with return value o Press any key to continue

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 Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

More Books

Students also viewed these Databases questions

Question

3. Comment on how diversity and equality should be managed.

Answered: 1 week ago

Question

describe the legislation that addresses workplace equality

Answered: 1 week ago