Purchase Solution

Using a Loop to Perform Operations Multiple Times

Not what you're looking for?

Ask Custom Question

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.

Purchase this Solution

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.

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. ...

Purchase this Solution

Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Javscript Basics

Quiz on basics of javascript programming language.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.