# Lab 8

Topics: Real number, Ring, Natural number Pages: 5 (319 words) Published: June 1, 2015
﻿Ruben Corrales
Pt1420
Erkam
Lab 8.1-3
Step 2:
The hour is 1 continue loop till the hour is 24 then stop.
Step 3:
Constant Integer Max_Minutes = 60
Declare Integer minutes
For minutes = 1 to Max_Minutes
Display “The minute is “, minutes
End For
Step 4:
Constant Integer Max_Seconds = 60
Declare Integer seconds
For seconds = 1 to Max_Seconds
Display “The second is “, seconds
End For
Step 6:
The number is 2
The number is 4
The number is 6
The number is 8
The number is 10
Step 7:
Constant Integer Max_VALUE = 200
Declare Integer counter
For counter = 20 to Max_VALUE step 20
Display “The number is “, counter
End For
Step 9:
Enter the number of students in class
Display however many numbered students you enter
Step 11:
Loop five times, each asking you to enter a number
Displaying the total at the end
Step 12:
Declare Integer counter
Declare Integer totalAge = 0
Declare Real averageAge = 0
Declare Integer age
Declare Integer number
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
averageAge = totalAge / number
Display “The average age is “, averageAge
Lab 8.2
Lab 8.3
Module Module1
Sub Main()
Dim anotherDay As String = "yes"
While anotherDay = "yes"
Dim totalSpeed As Double = 0
Dim averageSpeed As Double = 0
enterSpeeds(totalSpeed)
calcAverage(totalSpeed, averageSpeed)
displayAverage(averageSpeed)
Console.WriteLine("Enter yes if you want to calculate another day ") anotherDay = Console.ReadLine
End While
End Sub
Sub enterSpeeds(ByRef totalSpeed As Double)
Dim networkSpeed As Double = 0
Dim counter As Integer = 1
For counter = 1 To 8
Console.Write("Enter network speed at this hour: ")
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.WriteLine("The average network speed for the day is: " & averageSpeed & " Mbps.") End Sub
End Module