Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to figure out how to set up the nested loop to read the data from th

ID: 3656233 • Letter: I

Question

I am trying to figure out how to set up the nested loop to read the data from the input file. These are the directions: Use nested FOR loops to read all Data from the Input File, perform computations, and write all receipts of all customers to the output file. All input data must be validated by using IF statements. Strings should be validated for their lengths (use length member function, described on page 580 of the text book, to compute the string length); integer numbers should be between 1 and 100; floating point numbers should be between 1.00 and 500.00. Outer FOR loop will repeat for each customer. The inner FOR loop will repeat for each book bought by the outer loop customer. Since data is not available outside a loop, writing to the Output File will be performed in each loop. input data: Book Number: AB5326 Book Title: The Notebook Book Author: Nicholas Sparks Aisle Number: 15 Price of the Book: $90.55 Thanks for the help!

Explanation / Answer

You put one loop inside the other, like this:

#const MAX_I 100
#const MAX_J 100

for ( int i = 0; i < MAX_I; i++)
{
/* maybe do something here */
for ( int j = 0; j < MAX_J, j++ )
{
/* do something here */
}
/* maybe do something here also */
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote