The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I am trying to complete this lab. Could you use some help completing it.
VBScript IP Array LabObjectivesIn this lab, students will complete the following objecTves.Create a VBScript Program using NotePad++.Access a two-dimensional array.Use a Nested For Loop to display array contents.Use Do/While loops for error-handling.Use CStr( ), CInt( ), and chr( ) funcTons.Lab DiagramDuring your session you will have access to the following lab con±guraTon.Connecting to your labFor this lab, we will only need to connect toVlab-PC1.Vlab-PC1²o start simply click on the named WorkstaTon from the device list (located on the le³-hand side ofthe screen) and clickPower onin the tools bar. In some cases the devices may power onautomaTcally.During the boot up process an acTvity indicator will be displayed in the name tab.Black—Powered O´Orange—Working on your requestGreen—Ready to accessCOMP230_Wk4_ IPArray_Lab1Revision Date: 1213
If the remote console is not displayed automaTcally in the main window (or popup) click theConnecticon located in the tools bar to start your session.If the remote console does not appear please try the following opTon.Switch between the H±ML 5 and Java client versions in the tools bar.In the event this does not resolve your connecTvity problems please visit our Help/Support pages foraddiTonal resoluTon opTons.Task 1: Open IP_Array_start.vbsNote:All captures must be text only—DO NOT capture the NotePad++ applica±on window or thecommand prompt window. Use copy and paste of text only.Open NotePad++ and useFile/Opento openIP_Array_start.vbsin theC:\comp230directory. ModifytheProgrammer Headeras needed. andSave Asthe Fle with the new name ofIP_Array.vbs.±he linedim ipAddress(5,3)declares a6x42-dimensional array. ±he 5 and 3 give the maximumindex value. Because the index starts at 0, this is a 6x4 array.±he lines that follow iniTalize the array locaTons with IP addresses. ±he Frst index (0..5) representsthe rooms 100 through 105. ±he second index (0..3) represent the four computers in each room.Let’s visualize what the data in the ipaddress array looks like.Comp 1 (col 0)Comp 2 (col 1)Comp 3 (col 2)Comp 4 (col 3)Rm 100(row 0)192.168.10.11ipaddress(0,0)Ipaddress(0,3)Rm 101(row 1)Rm 102(row 2)Rm 103(row 3)Rm 104(row 4)Rm 105(row 5)Ipaddress(5,0)192.168.10.54Ipaddress(5,3)The grayed section represents your ipaddress array, which has 6 rows (numbered 0to 5) and 4 columns (numbered 0 to 3). To get a particular IP address requires you toselect the proper row and column.COMP230_Wk4_ IPArray_Lab2Revision Date: 1213
If you know the room number, to get the proper row for the data you need to subtract100. If you enter room 103, subtract 100 and you get row 3.If you know the computer number, to get the proper column for the data you need tosubtract 1. For computer 2, subtract 1 and you get column 1. The IP address of thethird computer in room 104 can be found in the array element or componentAddress(4,2). This value is“192.168.10.45”. Look at the array carefully to determinethe meaning of the index values.Now that you have an iniTalized two-dimensional array, it will be your job to query the array for theIP address for any computer (1–4) in any room (100–105).COMP230_Wk4_ IPArray_Lab3Revision Date: 1213
Task 2: Validate Input and Query Arrayfor IP Addresses1) Let’s start by defning our program variables. We need two sets oF variables:string variables:roomStrandcompStr; andnumber variables:roomandcomputer. String variables are needed Forinput and the number variables are used as indices For the ipaddress array.roomStrandcompStrwill store the values that are input by the user. (Remember that readlineassumes data input is string). They are then converted to the numerical values represen±ng row andcolumn using cint which are stored in theroomandcomputervariables.2) We frst need to prompt the user to enter the room number (100–105). We need to make surethat the user doesn’t enter a value less than 100 or greater than 105. Loops are useFul to validatedata. ²or example, iF I needed to input a number which is greater than 0 For some program and Iwant to make sure the input is posi±ve, I could do this with a While loop. The general pseudocodewould be as Follows.Read numberWhile number <= 0(a negative number is invalid data)Print error message, ask user to re-enterRead numberEnd WhileConsider how this works. IF the number entered is valid (greater than 0) then the condi±on is Falsethe frst ±me it is evaluated so the loop body is not executed. IF the number is invalid the user is held“hostage” in the loop un±l a valid value is entered.Suppose I enter -2 as the number.-2 <= 0 is true, so the loop is enteredThe user gets a message to re-enter a number greater than 0Maybe user s±ll doesn’t get it, and enters 0Now we are back to the loop condi±on0 <= 0 is trueThe user gets a message to re-enter a number greater than 0Now I enter 10The loop condi±on is evaluated10 <= 0 is ²ALSE, the loop endsNow the input is valid.COMP230_Wk4_ IPArray_Lab4Revision Date: 1213
We will use aWhileloop to validate the room value. Look at the pseudocode shown below and writethe required VBScript statement that implements the pseudocode task. Vbscript code that is correctas wriTen will be inbold.Display Prompt “Please Enter the Room Number (100-105) ......“Get StdIn Console Input and assign string value to roomStrroom = CInt(roomStr)While room < 100 OR room > 105Use StdOut to Beep Speaker twice with chr(7)Display ErrMsg “Error, 100 to 105 Only!!!”Display Prompt “Please Enter the Room Number (100-105) ......“Get StdIn Console Input and assign string value to roomStrroom = CInt(roomStr)End WhileSave and test this code before con±nuing. Enter an INVALID room number. You should get the errormessage. Enter a VALID room number and the program should exit.3) Now we prompt the user for the computer number (1–4). We need to make sure that the userdoesn’t enter a value less than 1 or greater than 4. We will again use aWhileloop to error-handlethis value. Look at the Pseudocode shown below and write the required VBScript statement thatimplements this pseudocode task. Real code that is correct as wriTen will be inbold.Display Prompt “Please Enter the Computer Number (1-4) ......“Get StdIn Console Input and assign string value to compStrcomputer = CInt(compStr)While computer < 1 OR computer > 4Use StdOut to Beep Speaker twice with chr(7)Display ErrMsg “Error, 1 to 4 Only!!!”Display Prompt “Please Enter the Computer Number (1-4) ......“Get StdIn Console Input and assign string value to compStrcomputer = CInt(compStr)End While²est to make sure an INVALID computer number is detected.4) Now that we have a valid room number100–105and a valid computer number1–4, let’s displaythe IP address for the speciFed room and computer.Use a vbscript output statement to display thedata (the statement below is psuedocode).Display message " The IP Address in Room "roomStr" for computer "compStr"is "ipAddress(room-100,computer-1)COMP230_Wk4_ IPArray_Lab5Revision Date: 1213
Note:For room 102, Computer 2, the IP Address is found at ipAddress(2,1). How do you convertroom 102 to index 2 and Computer 2 to index 1?Test with various room/computer values. Make sure you input an INVALID room and computer ±rst,then a VALID room and computer (in order to verify that the data valida²on loops work.)Task 3: Prompt User to Display All IP Addresses inArrayNow con²nue your program by adding the code that follows the pseudocode shown below toprompt the user if they would like to display the en²re table of IP addresses. Real code that is correctas wri³en will be in bold.Display All IP Address Y/N?Display Message"Do you wish to Display all of the IP Addresses (Y/N) ..... "Get User Response and assign it to variable ansIf ans = "Y" OR ans = "y" Thenskip lineFor room = 0 to 5For computer = 0 to 3Display "The IP Address in Room " (room+100) " for Computer "(computer+1) " is " ipAddress(room,computer)NextNextEnd IfNote:Nested For/Next loops are required to access all the elements of a two-dimensional array.Task 4: Finish Program and Run it Showing Error-Handling1) Finish wri²ng your program. Include comments as needed and use proper rules for indenta²on.Run your program usingfrom a command windowusingcscript IP_Array.vbsso that error-handlingfor Room and Computer is tested. Make sure your submi³ed run displayed the IP Address of aselected room and computer and displays the en²re array of IP addresses. A sample run is shown onthe next page.COMP230_Wk4_ IPArray_Lab6Revision Date: 1213
Copy and paste your final program sourcecode and your final RUN into the spacesprovided in your lab-report document. Submit your completed lab-report document tothe iLab Dropbox for this week.COMP230_Wk4_ IPArray_Lab7Revision Date: 1213
-----------