You are on page 1of 4

Lab8.

1 loop and accumulation with pseudocode


Step 2 This for loop writes the hour on the screen from 1 to 24
Step 3 Constant integer max_minutes = 60
Declare integer minutes

For minutes =1 to max_minutes


Display the, minutes
End for
Step 4 Constant integer max_seconds =60
Declare integer seconds

For seconds =1 to max_seconds


Display the seconds is, seconds
End for

Step 6 this for loop it writes the number on the screen but only counts up by 2 so
the numbers\
Would be 0, 2 ,4, 6, 8, and 10
Step 7 constant integer max_value = 200
Declare counter

For counter = 20 to max_valuestep 2


Display the number is, counter
End for
Step 9 this for loop it writes the number of students that are in the class from 1 to
however students that are input

Step 11 this for loop displays the total of the sum of the 5 numbers that are
inputted
Step 12 declare integer counter
Declare integer totalage = 0
Declare real age = 0
Declare integer age

Display how many ages do you want to enter


Input number

For counter = 1 to number


Display enter age
Input age
Set totalAge = totalAge + age
End for
Average age = totalAge/number
Display the average age is averageAge
8.2

8.3
Module Module1
Sub Main()
Dim anotherDay As String = "yes"
While anotherDay = "yes"
Dim totalSpeed As Integer = 0
Dim averageSpeed As Integer = 0
Call enterSpeeds(totalSpeed)
Call calcAverage(totalSpeed, averageSpeed)
Call displayAverage(averageSpeed)
Console.WriteLine("Enter yes if you wnat to calculate another day:")
anotherDay = Console.ReadLine
End While
End Sub
Sub enterSpeeds(ByRef totalSpeed As Integer)
Dim networkSpeed As Double = 0
Dim counter As Integer = 1
For counter = 1 To 8
networkSpeed = Console.ReadLine
totalSpeed = totalSpeed + networkSpeed
Next
End Sub
Sub calcAverage(ByVal totalSpeed As Double, ByRef averageSpeed As Double)
averageSpeed = totalSpeed / 8
End Sub
Sub displayAverage(ByVal averageSpeed As Double)
Console.Write("The average network speed for the day is" & averageSpeed)
Console.ReadLine()
End Sub
End Module

You might also like