Cash-back offer from April 23rd to 27th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 30.00

PT1420: Repetition Structures in Visual Basic | Step 3,4,5 Solved

Question posted by
Online Tutor Profile
request

PT1420: Repetition Structures in Visual Basic

This lab requires you to write the program in the Visual Basic 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 file  New project
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()
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 to debug  start debugging 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:
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
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

Call collectAndValidateName()
Console.Write("Press any key to close")
Console.ReadLine()
End Sub
Your module looks like this:


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
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 to debug  start debugging
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
 


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

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 to debug  start debugging
e. Test you code to make sure you have to provide each piece of information 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:
PT1420: Repetition Structures in Visual Basic

(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:\Users\instructor\Documents\Visual Studio 2010\Projects\myFirstProgram\myFirstProgram\Module1.vb; in this case navigate to C:\Users\instructor\Documents\Visual Studio 2010\Projects). 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

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?

Available Answer
$ 30.00

[Solved] PT1420: Repetition Structures in Visual Basic | Step 3,4,5 Solved

  • This solution is not purchased yet.
  • Submitted On 15 Jul, 2015 08:58:32
Answer posted by
Online Tutor Profile
solution
This Tutorial is rated A+ p...
Buy now to view the complete solution
Other Similar Questions
User Profile
Exper...

PT1420: Repetition Structures in Visual Basic | Step 3,4,5 Solved

This Tutorial is rated A+ previously,if you have any questions regarding this tutorial then you can contact me....

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35