Explore BrainMass

Using a Loop to Perform Operations Multiple Times

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

This is a program that I am working on. It is supposed to simulate the roll of a pair of dice 100 times, then write the results to a file. Once the file is written, the user clicks the read file button to read the file. I have the write file/roll dice button working. I have the read file working, it displays the results in a textbox. What I need help with is to get the dice to roll 100 times instead of just one. So the read file results will show the results of 100 rolls of the dice. The file tab also has instructions as to how the program should work.

See the attached file.

© BrainMass Inc. brainmass.com October 25, 2018, 8:10 am ad1c9bdddf


Solution Preview

All computer programming languages have what are called Control Structures. They include branching structures ("if" and "case" statements) and looping structures ("while" loops, "for" loops, etc.).

The subset of Control Structures called "loops" allow you to execute commands multiple times, while only writing those commands once. The general flow of control in a loop is as follows:

A logical expression is evaluated. If it is true, the statements within the loop will be executed one at a time, until the bottom of the loop is reached. At that point the control returns to the top of the loop and the logical expression is checked again. If it is still true, the same statements within the loop are executed again, until the bottom of the loop is reached, and control returns to the top of the loop. If the control has returned to the top of the loop and the logical expression is considered false, the control of the program jumps to the first statement after the loop.

Please understand that is a general description of the flow of control. There are types of loops, for example, where the statements are always executed at least once, because the logical expression that controls whether the loop is executed is at the bottom of the loop. ...

Solution Summary

In this brief document you will be shown how using a loop structure will allow you to execute the same commands multiple times. A thorough explanation of the flow of control when a loop is encountered is also presented.

See Also This Related BrainMass Solution

Question about software packages

Need help with:

1. Identifying various software systems available to firms in these materials requirements planning (MRP), capacity requirement planning (CRP), enterprise resource planning (ERP), supply chain management, inventory control, shop floor control, and production planning scheduling needs and the pros and cons of each system.

2. How do you a write a "Software Recommendations Report" to the chief executive in which you recommend specific software systems for the firm? What would it look like withe the info obtained above? How would you justify the recommendation of comparable software systems?

View Full Posting Details