Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I do not know where I am wrong, so ,could you help me fixed here is my code: #include #include using namespace std; int main()

I do not know where I am wrong, so ,could you help me fixed

here is my code:

#include #include using namespace std;

int main() { ifstream appleFS; string fileName; int appleCount; int leftoverCount;

cin >> fileName; appleFS.open(fileName); if (!appleFS.is_open()) { cout

leftoverCount = 369;

/* Your code goes here */ if(appleFS.eof()){ return true; } while (!appleFS.fail()&&!appleFS.eof()) { appleFS >> appleCount; leftoverCount = leftoverCount- appleCount; cout

image text in transcribedimage text in transcribed

String fileName is read from input. The opened file named fileName contains counts of apples ordered by a grocery store, and is associated with the stream appleFS. Using a loop, read integers from the opened file and subtract each integer from leftoverCount. If an error occurs in a read operation, then the loop should terminate. Ex: If the input is data4. txt, then the output is: 81 64 98 19 42 Unused: 65 \begin{tabular}{l|l} \multicolumn{1}{r|}{ Input } & data4.txt \\ & 81 \\ & 64 \\ Your output & 98 \\ & 19 \\ & 42 \\ & Unused: 65 \\ \hline \end{tabular} 2: Compare output Output differs. See highlights below. Special character legend X 3: Compare output Output differs. See highlights below. Special character legend \begin{tabular}{l|l|} \multicolumn{1}{r|}{ Input } & data2.txt \\ & \\ & 71 \\ Your output & 57 \\ & 29 \\ & 04 \\ & Read operation failed \end{tabular}

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

8-6 Who poses the biggest security threat: insiders or outsiders?

Answered: 1 week ago