Answered step by step
Verified Expert Solution
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
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started