You are on page 1of 1

Question Format Pseudocode VB.

Net Program
May/June 2014 P12 Module Module1
Name” “ Sub Main()
A school has 1500 students. It is conducting a survey on their music Count0 Dim Name As String =”””
preferences. Each student uses a computer and inputs their name and Initialization Choice0 Dim Choice As Integer=0
then chooses one of 5 options: ([Variable]Initial Value) CountA0 Dim Count As Integer=0
• rock (input value 1) CountB0 Dim CountA As Integer=0
• soul (input value 2) For Count Starting Value to End Value CountC0 Dim CountB As Integer=0
• pop (input value 3) Input [Variable] CountD0 Dim CountC As Integer=0
• jazz (input value 4) CountE0 Dim CountD As Integer=0
• classical (input value 5) Value Calculation (if required) PerA0 Dim CountE As Integer=0
Write an algorithm, using pseudocode or a flowchart, which: Output Calculated Value ([Variable]) PerB0 Dim PerA As Integer=0
• inputs the choice of all 1500 students (values 1 to 5) PerC0 Dim PerB As Integer=0
• outputs all the names of the students who chose classical music Totaling (if average is required) PerD0 Dim PerC As Integer=0
• outputs the percentage who chose each option. (TotalTotal+[Variable]) PerE0 Dim PerD As Integer=0
Iterative FOR Count1 TO 1500 Dim PerE As Integer=0
Count Base Condition Based Counting based on condition (if sub-set READ Name, Choice For Count= 1 To 1500
Value Extreme data to find) CASE Choice OF Name=Console.ReadLine()
Totaling Counting % 1: CountACountA+1
Calculation Value Choice =Console.ReadLine()
(IF { conditional statement } THEN 2: CountBCountB+1 Select Choice
Variables to be CountACountA+1) 3: CountCCountC+1 Case 1
Data Type to Store/Count 4: CountDCountD+1
used Extreme values (if highest/lowest to CountA=CountA+1
Count Integer No of iteration 5: CountECountE+1 Case 2
find) PRINT Name CountB=CountB+1
Name String Name of Student
Choice Integer Choice of music (IF [Variable]>Highest THEN ENDCASE Case 3
NEXT CountC=CountC+1
Students who have
CountA/Rock Integer Highest [Variable]) PerA(CountA/1500)*100 PerB(CountB/1500)*100 Case 4
chosen Rock music
(IF [Variable]<Lowest THEN PerC(CountC/1500)*100 CountD=CountD+1
Students who have
CountB/Soul Integer PerD(CountD/1500)*100 Case 5
chosen Soul music Lowest [Variable]) PerE(CountE/1500)*100 CountE=CountE+1
Students who have
CountC/Pop Integer Next PRINT PerA, PerB, PerC, PerD, PerE Console.WriteLine(Name)
chosen Pop music
Students who have End Select
CountD/Jazz Integer Calculate Average NEXT
chosen Jazz music
% of students who have (AvgTotal/Loop End Value) PerA=(CountA/1500)*100
PerA/RockPer Real PerB=(CountB/1500)*100
chosen Rock music Calculate Percentage
% of students who have PerC=(CountC/1500)*100
PerB/SoulPer Real (Per(CountA/Loop End Value)*100 PerD=(CountD/1500)*100
chosen Soul music
% of students who have PerE=(CountE/1500)*100
PerA/RockPer Real Output Average, Counting Variables, Extreme Values, % Console.WriteLine (PerA & PerB & PerC &
chosen Rock music
PerD & PerE)
% of students who have
PerB/SoulPer Real End Sub
chosen Soul music
End Module

(You can try this code online at


http://ideone.com/H5bzUv)

You might also like