VisualBasic
CIS121 Logic and Design
In this course, we used the textbook, Tools for Structured and Object-Oriented Design: An Introduction to Programming Logic - 6th ed., by Marilyn Bohl and Maria Rynn. We were usually given about an hour to work on most labs.
Please click Help for help setting up and using these project files.
Total Numbers
To view this file, right-click and choose save as. When you double-click the file to run it, it will prompt you to input a number to add. It will continue to ask for more numbers to add to the sum until you input the word "stop". This file is actually a variation on the original lab, which called for the user to input "-1" to finish submitting numbers. After I finished the lab, I went on to create this variation, which I prefer. We were told to program as if "Aunt Sally" was going to be the user so we needed to be clear and plain in interfacing with the user. Entering a "-1" doesn't seem like a very intuitive thing for "Aunt Sally" - or anyone else, for that matter - to do to make something stop.
Instructions
This is the original lab problem.
- Recall Lab 5 in which we had a VBScript that totaled six numbers. This time we will total a variable number of numbers. The user will indicate that he/she is done submitting numbers by entering a -1.
Start TOTAL = 0 READ NUM from user DOWHILE NUM <> -1 TOTAL = TOTAL + NUM READ NUM ENDDO PRINT TOTAL Stop- Use the pseudocode as a guide to create a VBScript. Be sure to give the user good prompts and output, so that he/she understand what is happening.
- Test the script.
- Demo the script for your instructor.
Magic 8 Ball
To view this file, right-click and choose save as. When you double-click the file to run it, it will answer the user's life question. Ask anything you want, and see what the Magic 8 Ball has for your burning questions.
Case with Modules
To view this file, right-click and choose save as. When you double-click the file to run it, it will simulate a simple order process. It will prompt you to choose one of four products. Then you will be prompted for specific variations of the selected product, and then it will read back to you your choices.
The original lab was written so that you could literally enter anything you want for certain inputs; whereas it did limit your choices on other inputs. For example, there were no defined limitations on the shirt size input or the shirt color input. However, other inputs would have finite choices such as sleeves being only short or long.
Apparently, I went overboard on this lab and went on to create extra parts in the program that would test for valid entries for inputs with finite choices defined in the original lab. I didn't get extra credit, although it did make me feel better, and my instructor thought it was cool. I would have preferred lists of choices for each input and tested every input for valid entry.
Instructions
This is the original lab problem.
- Below is pseudocode for processing users orders for a limited number of products. Note the use of the Case structure and that each branch of the case calls a subroutine.
Start Read item type (shirt, pants, shoes, or hat) ltype = lower case (type) select case ltype Case shirt processShirt Case pants processPants Case shoes processShoes Case hat processHat Case else write "Please select from shirt, pants, shoes, or hat" End select Stop ============== Subroutines ============== Sub processShirt Read shirt size, color, short or long sleeve Write entries back to the user. End Sub Sub processPants Read waist size, inseam and color Write entries back to the user. End Sub Sub processShoes Read style (running, walking or court) and size Write entries back to the user. End Sub Sub processHat Read style (baseball, beachhat or fedora) and size Write entries back to the user. End Sub- Use the pseudocode as a guide to create a VBScript. Be sure to give the user good prompts and output, so that he/she understands what is happening.
- Test the script.
- Demo the script for your instructor.