Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So the code runs, #include #include #include #include using namespace std; int main() { ifstream in; ofstream out; in.open(Exp3.txt); if (!in) { cout out.open(Exp3.txt); if

image text in transcribed

So the code runs,

#include #include #include

#include

using namespace std;

int main() { ifstream in;

ofstream out;

in.open("Exp3.txt"); if (!in) { cout

out.open("Exp3.txt"); if (!out) { cout > name >> unit >> price; cout

although I'm unable to bring out any results.

image text in transcribed

CS1 Lab 15 Write a C++ program to read the data from an ASCII file (text file), which has the inventory data for a store. Use only windows notepad to create this file, otherwise there may be extra characters in the file. The file has the data written to file in the following sequence for each part in the inventory. Part name (one word only), number of units in inventory (integer data), unit price (floating point data). The sample lines from the file looks like the Figure 1 below. Exp3. txt - Notepad Chisel 50 9.99 Hanner 30 15.99 Nails 2006 0.99 Bolts 200 2.99 Nuts 300 1.99 Soap 55 1.891 FIG 1 This structure of file will allow you to use only extraction operator>> to read all data. Read the data from file and calculate the value of inventory first for each item. For example for Chisel it would be 50-9.99 - 499.50 Then sum up the values for all items in the file to find Total cost of the inventory in dollars. Then output the data into an output file where it is formatted in a Table form that looks like the Figure 2 below: Inventory Report For Jane Doe International Hardware ITEM NUMBER OF UNITS UNIT COST (S) TOTAL VALUE (5) 499.50 50 9.99 Chisel Inventory Total (S) 2000.45 Perfect alignment is required. The names of parts must all be left justified, so that first letter of each part name aligns in the same vertical line. All numbers must be right justified, so that last digit of each line in each column aligns in the same vertical line. Numbers must be centered in each column. The inventory total must be aligned as shown in the Figure 2 above. For those float numbers, where price or total value rounds off to whole dollar, the price must be printed such as 12.00, not 12. CS1Lab.c GS Microsoft Visual Studio Debug Console # CS1La Not able to open Exp3.txt for reading C:\Users\scope\Desktop\2022 C++ WINTER\Projects\CS1Lab\Debug\Csilab.exe (process 9100) exited with code -1. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the conso le when debugging stops. Press any key to close this window

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago