Question: MODULE #3 -FOR & WHILE LOOPS How many credit hours are being taken by the students in this class? What are the total amounts of


MODULE #3 -FOR & WHILE LOOPS How many credit hours are being taken by the students in this class? What are the total amounts of tuition students have paid that are enrolled in the CIS 125 course? How many work hours have all the employees put in this week? Notice for each example that we will NOT be counting by 1 to come up with the right calculation but coming up with a running total. An accumulator variable is used for this purpose. Please review the following accumulator variable that is used to answer the question of how many work hours have all the employees put in this week? iTotalHours = iTotalHours + iEmployee Hours Program Example of a Counter and an Accumulator Typically a counter or an accumulator variable involves an assignment statement inside a loop structure. Let's now look an example of a program that prompts for how many numbers the user will enter and then display the following information: The total value of all the numbers entered The number of values that are even Review the Visual Logic Flowchart for this program on the next page... MODULE #3 -FOR & WHILE LOOPS final value, control flows to the symbol after the For Loop symbol. We will now review a couple of For Loop examples... Number of times Loop is repeated? For Loop Example For A - 2 to 10 Step 2 For A - 50 to 1 Step - 1 For A = 1 to 100 Step 20 For A=1 to 1 Step 1 For A=1 to 0 Step 1 For A=1 to 0 Step - 1 MODULE #3 -FOR & WHILE LOOPS Practice Exercise Set #3 1. Read the Loop Structure explanation and correctly write a For Loop statement. The first one has been done for you: Loop structure explanation For Loop Statement Create a For Loop structure that will start with For I - 10 to 20 Step 2 10 and count by 2 up to 20. Create a For Loop structure that will start with 50 and count down to using increments of I. Create a For Loop structure that will perform a process for each letter of the alphabet. 2. Read cach calculation that is needed and determine if you would need a counter variable or an accumulator variable? Calculation Counter or Accumulator? How many students are under 20 years old? How many male students are Dearbom residents What is the total amount that has been sold for all salespeople? What is the total number of sales people whose gender is female? What is the total amount of commissions paid to all sales people? 3. Write a Visual Logic Flowchart that uses a loop to display "Ho Ho Ho Merry Christmas" to console output. Your program should use the word Ho only once. 4. Create a Visual Logic Flowchart that will display the squares of the numbers 1 to 10 in a console output window 5. Create a Visual Logic Flowchart that uses a For Loop to read exactly five values from the user and then display their average. Use the Console for input and output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
