You are on page 1of 6

Case 1

A class of 15 students took a Test. The grades for this test are available to you.
Create a program that computes for the Class Average.

Sub main()

Dim total As Integer

Dim gradeCounter As Integer

Dim grade As Integer

Dim average As Double

Total = 0

gradeCounter = 1

While gradeCounter <= 15

Console.write("Enter grade:")

grade = console.readline()

Total += grade

gradeCounter += 1

End while

average = total / 15

Console.writeline()

Console.writeline("Class average is {0}", average)

End Sub
Case 2

Create a program that averages an

arbitrary number of score each time the program is run.

Main Sub()

Dim total As Integer

Dim scorecounter As Integer

Dim score As Integer

Dim average As Double

Total = 0

scorecounter = 0

Console.Write("Enter score, -1 to quit: ")

score = Console.ReadLine()

While score <> -1

total += score

scoreCounter += 1

Console.Write("Enter score, -1 to quit: ")

score = Console.ReadLine()

End While

End Sub
Case 3

A High School offers a review session that prepares students for the entrance
exam for College. Last year, 15 of the students who completed this review
session took the entrance examination. The High School wants to know how
well its students did on the exam. You have been asked to write a program to
summarize the results. You have been given a list of the 15 students. Next to
each name is written a “P” if the student passed the exam and an “F” if the
student failed the exam.

Sub Main()

Dim passes As Integer = 0

Dim failures As Integer = 0

Dim student As Integer = 1

Dim result As String

While student <= 15

Console.Write("Enter result (P = pass, F = fail): ")

result = Console.ReadLine()

If result = "P" Then

passes += 1

Else

failures += 1

End If

student += 1

End While
Console.WriteLine("Passed: {0}{1}Failed: {2}", passes, _

vbCrLf, failures)

If passes > 13 Then

Console.WriteLine("Raise Tuition")

End If

End Sub

Case 4

Sub Main()

Write a program that draws in the command window a filled rectangle


consisting solely of * characters. The side of the rectangle should be entered
by the user and should not exceed 30.

Sub Main()

Dim side As Integer

Dim row As Integer = 1

Dim column As Integer

Console.Write("Enter side length (must be 30 or less): ")

side = Console.ReadLine()

If side <= 30 Then

While row <= side

column = 1

While column <= side


Console.Write("* ")

column += 1

End While

Console.WriteLine()

row += 1

End While

Else

Console.WriteLine

End If

End Sub

You might also like