PT1420: Decision Structures in Pseudocode and Visual Basic
Page 1
This lab requires you to think about the steps that take place in a program by writing
pseudocode. Read the following program prior to completing the lab.
Career Tech Placement is hiring employees for placement at technology firms across the
city. Prior to granting an interview, the company has a 100-point test that is used to
determine if the candidate should be interviewed. Depending on the candidate’s score,
he or she will be placed in 1 of 4 categories for possible employment and flagging for an
interview:
Score Employment Category Interview Possibility
85 or above Definite Yes
70 – 84 Likely Yes
60 – 69 Maybe Yes
59 or below No No
Career Tech Placement has asked you to write a program that will allow the company to
enter a test score and then set the employment category and the interview possibility
variables based on the chart above.
Given the major task involved in this program, you decide your program should have three
variables and three modules:
Variable Name Purpose
Declare Integer testScore = 0 Stores the test score of the candidate.
Declare String category = “ “ Stores Definite, Likely, Maybe, or No
Declare String interview = “ “ Stores Yes or No
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 2
Module Name Purpose
Module getScore() Allows the user to enter the test score
Module employCat() Determines the employment category
Module interviewPoss() This module will determine if a day off should
be awarded.
Module displayInfo() Displays the testScore, category, and interview
variables.
Step 1: Complete the pseudocode by writing the missing lines. When writing your modules and
making calls, be sure to pass necessary variables as arguments and accept them as reference
parameters if they need to be modified in the module (Reference: Testing a Series of
Conditions, page 138 from your textbook, Starting Out with Programming Logic & Design.).
Main Module()
//Declare variables on the next 3 lines
//Make Module calls and pass necessary variables on the next 4 lines
End Main
Module getScore(Integer Ref testScore)
//Ask the user to enter a test score
End Module
Module employCat(Integer testScore, String Ref category)
//Determine what employment category they are in based on their test score
//Similar to if the score is less than 60, then category is “No”
PT1420: Decision Structures in Pseudocode and Visual Basic
...
A Critique of the Proposed National Education Policy Reform
PT1420: Decision Structures in Pseudocode and Visual Basic
1. PT1420: Decision Structures in Pseudocode and Visual Basic
Page 1
This lab requires you to think about the steps that take place in
a program by writing
pseudocode. Read the following program prior to completing
the lab.
Career Tech Placement is hiring employees for placement at
technology firms across the
city. Prior to granting an interview, the company has a 100-
point test that is used to
determine if the candidate should be interviewed. Depending on
the candidate’s score,
he or she will be placed in 1 of 4 categories for possible
employment and flagging for an
interview:
Score Employment Category Interview Possibility
85 or above Definite Yes
70 – 84 Likely Yes
2. 60 – 69 Maybe Yes
59 or below No No
Career Tech Placement has asked you to write a program that
will allow the company to
enter a test score and then set the employment category and the
interview possibility
variables based on the chart above.
Given the major task involved in this program, you decide your
program should have three
variables and three modules:
Variable Name Purpose
Declare Integer testScore = 0 Stores the test score of the
candidate.
Declare String category = “ “ Stores Definite, Likely, Maybe, or
No
Declare String interview = “ “ Stores Yes or No
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 2
3. Module Name Purpose
Module getScore() Allows the user to enter the test score
Module employCat() Determines the employment category
Module interviewPoss() This module will determine if a day off
should
be awarded.
Module displayInfo() Displays the testScore, category, and
interview
variables.
Step 1: Complete the pseudocode by writing the missing lines.
When writing your modules and
making calls, be sure to pass necessary variables as arguments
and accept them as reference
parameters if they need to be modified in the module
(Reference: Testing a Series of
Conditions, page 138 from your textbook, Starting Out with
Programming Logic & Design.).
Main Module()
//Declare variables on the next 3 lines
//Make Module calls and pass necessary variables on the next 4
lines
4. End Main
Module getScore(Integer Ref testScore)
//Ask the user to enter a test score
End Module
Module employCat(Integer testScore, String Ref category)
//Determine what employment category they are in based on
their test score
//Similar to if the score is less than 60, then category is “No”
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 3
//Otherwise, if score is less than 70 then category is “Maybe”
//…and so on
End Module
Module interviewPoss(Integer testScore, String Ref interview)
//Determine if they qualify for an interview based on their test
score
//Similar to if the score is less than 60, then interview is “No”
//Otherwise, interview is “Yes”
5. End Module
Module displayInfo(Integer testScore, String category, String
interview)
//Display the three variables
End Module
This lab requires you to convert the pseudocode and flowchart
into an actual program using
Visual Basic.
Step 1: Launch Visual Basic and create a new Console
Application. Save it to the appropriate
location.
Step 2: We will be using modules in this program, so all
variables and module calls will go
between of Sub Main() and End Sub. In VB, start by declaring
and initializing your variables and
making module calls such as:
Sub Main()
'declare your 3 variables similar format such as
'Dim variableName As DataType = 0 (or “ “ if it’s a string)
6. PT1420: Decision Structures in Pseudocode and Visual Basic
Page 4
'call your 4 modules and pass necessary variables similar
'format such as
'moduleName(arguments)
'add this to cause a pause
Console.WriteLine("Press enter to continue...")
Console.ReadLine()
End Sub
Your module looks like this:
Step 3: Code the getScore() module so that the user enters a test
score. Remember to use
ByRef so the value of testScore is retained. This module will
look like:
Sub getScore(ByRef testScore As Integer)
'add the code to input testScore
End Sub
7. PT1420: Decision Structures in Pseudocode and Visual Basic
Page 5
Step 4: Code the employCat() module that will determine the
category placement. Remember
to use ByRef so the value of category is retained. This module
will look like:
Sub employCat(byVal testScore as Integer, byRef category as
String)
'add the code to evaluate conditions
If testScore < 60 Then
category = "No"
ElseIf testScore < 70 Then
category = "Maybe"
ElseIf testScore < 85 Then
category = "Likely"
Else
category = "Definite"
8. End If
End Sub
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 6
Your module may look like this:
Step 5: Code the interviewPoss() module that will determine the
interview value. Use ByRef for
interview, and byVal for testScore. This will be a simple If
Then Else that will set the interview
variable to either “Yes” or “No.
Step 6: Code the displayInfo() module and use
Console.WriteLine() to display the values of the
three variables. All three variables can be passed as ByVal.
9. PT1420: Decision Structures in Pseudocode and Visual Basic
Page 7
Step 7: Save, build, and execute your program so that it works.
Your output might look like this:
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 8
Step 8: Submit the Visual Basic code as a compressed (zipped)
folder using the following steps:
a. Open Windows Explorer --> Start --> All Programs -->
10. Accessories --> Windows Explorer.
Your Windows Explorer might look as follows:
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 9
b. In Windows Explorer, navigate to the folder that contains
your project files. Your
Windows Explorer might look as follows:
(If you don't recall you can check in Visual Studio by opening
your project, right click
module1.vb file and view the properties. Look at the full path
ex.
C:UsersinstructorDocumentsVisual Studio
2010ProjectsmyFirstProgrammyFirstProgramModule1.vb; in
this case navigate to
C:UsersinstructorDocumentsVisual Studio 2010Projects).
Your module properties
might look as follows:
11. c. Right click on your project folder and choose send to -->
compressed folder. This creates
a zip file of all your code. Your Windows Explorer might look
as follows:
PT1420: Decision Structures in Pseudocode and Visual Basic
Page 10
d. Attach the compressed folder you created to your submission.
Your Windows Explorer
might look as follows:
PT1420: Repetition Structures in Visual Basic
Page 1
This lab requires you to write the program in the Visual Basic
12. console application using loops.
Read the following program prior to completing the lab.
Food Incorporated wants you to create a small program that will
ask customers to enter their
name, address, city, state, zip code and to validate that they
provide the information in order to
complete the program.
Complete the following lab tasks.
Step 1: Start the program
a. Create a new Visual Basic Console Application by going to
b. Name the application lab4.2_fname_lname and click Ok
Step 2: Create the initial code asking for the user’s name
a. In the main function write the following code to request a
user to enter their
name and pause the program when finished:
'Create the variables
Dim strFname As String = “”
Console.Write("Enter your first name:")
strFname = Console.ReadLine()
13. Console.Write("Hello " & strFname & vbCrLf)
Console.Write("Press any key to close")
Console.ReadLine()
PT1420: Repetition Structures in Visual Basic
Page 2
Your module looks like this:
b. Run the program by clicking the green arrow that points to
the right or by going
Test your program by first entering your name; observe what
happens.
Test your program again but this time just press Enter. Note,
nothing
stopped you from entering your name. Your output looks like
this:
14. PT1420: Repetition Structures in Visual Basic
Page 3
Step 3: Add a module to collect input
a. Create a new module called collectAndValidateName() and
move the input of
the users information to this module. Update your main function
to look like the
following:
Sub collectAndValidateName()
'Create the variables
Dim strFname As String = ""
'Create the first validation loop
'Prompt for user to enter name
Console.Write("Enter your first name:")
'Read user input
15. strFname = Console.ReadLine()
'check if the user entered a value
Console.Write("Hello " & strFname & vbCrLf)
Console.Write("Press any key to close")
Console.ReadLine()
b. Call your collectAndValidateName() module from the main()
module. Update
your main function to look like the following:
Sub Main()
PT1420: Repetition Structures in Visual Basic
Page 4
Call collectAndValidateName()
Console.Write("Press any key to close")
Console.ReadLine()
End Sub
Your module looks like this:
16. Step 4: Add Input Validation using a do while loop
a. We will now add the code to make sure that the user submits
their name before
we continue and say hi to them. Update your collect
AndValidateName module
to look like the following:
'Create the first validation loop
Do While strFname = ""
'Prompt for user to enter name
Console.Write("Enter your first name: ")
'Read user input
PT1420: Repetition Structures in Visual Basic
Page 5
strFname = Console.ReadLine()
'check if the user entered a value
If strFname = "" Then
17. Console.Write("You did not enter a value, try again"
& vbCrLf)
End If
Loop
Console.Write("Hello " & strFname & vbCrLf)
End Sub
b. Run the program by clicking the green arrow that points to
the right or by going
g
o Test your program by first entering your name, observe what
happens
c. Test your program again but this time just hit enter. Note that
your program now
requires you to enter your name before continuing to say hello
to them. Your
output looks like this:
PT1420: Repetition Structures in Visual Basic
Page 6
18. Step 5: Add additional code to ask the user to enter their
address, city, state and zip code. You
can use any of the looping methods covered in this week’s
material.
a. Using step 3 create additional modules to validate that the
user provides his or
her address, city, state, and zip code. Your module looks like
this:
PT1420: Repetition Structures in Visual Basic
Page 7
b. Using step 4, create loops to validate that the user provides
his or her address,
city, state, and zip code.
c. Write out to the screen the information that the user provided.
d. Run the program by clicking the green arrow that points to
the right or by going
e. Test you code to make sure you have to provide each piece of
information
19. before exiting the program. Your final output looks like this:
PT1420: Repetition Structures in Visual Basic
Page 8
PT1420: Repetition Structures in Visual Basic
Page 9
Step 6: Submit the Visual Basic code as a compressed (zipped)
folder using the following steps:
a. Open Windows Explorer --> Start --> All Programs -->
Accessories --> Windows Explorer.
Your Windows Explorer might look as follows:
b. In Windows Explorer, navigate to the folder that contains
your project files. Your
Windows Explorer might look as follows:
20. PT1420: Repetition Structures in Visual Basic
Page 10
(If you don't recall you can check in Visual Studio by opening
your project, right click
module1.vb file and view the properties. Look at the full path
ex.
C:UsersinstructorDocumentsVisual Studio
2010ProjectsmyFirstProgrammyFirstProgramModule1.vb; in
this case navigate to
C:UsersinstructorDocumentsVisual Studio 2010Projects).
Your module properties
might look as follows:
c. Right click on your project folder and choose send to -->
compressed folder. This creates
a zip file of all your code. Your Windows Explorer might look
as follows:
PT1420: Repetition Structures in Visual Basic
21. Page 11
d. Attach the compressed folder you created to your submission.
Your Windows Explorer
might look as follows:
THOUGHT QUESTIONS:
1. Were you able to successfully complete the code to validate
the address, city, state, and
zip code? If not, what went wrong?
2. What types of loops did you try to use in this assignment?
3. What are some ways that you think this program could be
improved?