A Guide to Working with Visual Logic - Vocabulary Flashcards
Visual Logic Notes
- A computer program is a solution to a problem.
- Most useful programs do at least 3 things: input data, process data, output resulting information.
- Visual Logic emphasizes the Input → Process → Output flow, often shown explicitly as INPUT PROCESS OUTPUT.
- Data items involved:
- Customer ID
- Mailing address
- Credit card number
- Product
- Procedures the system performs:
- Connect to Database
- Determine product cost
- Calculate sales tax
- Bill customer
- Print customer receipt
- Generate shipping label
- Generate report for sales department
- Emphasizes the same IO structure: INPUT → PROCESS → OUTPUT.
Algorithms, Flowcharts, and Pseudocode
- An algorithm is the blueprint for a computer program/software.
- Tools for representing algorithms include:
- Visual Logic is a visual tool that combines graphics of flowcharts with pseudocode-like syntax.
- Visual Logic can animate or execute the algorithm.
- Important distinction: Visual Logic is NOT a computer programming language.
- After an algorithm is developed, it must be coded in a programming language to be run on a computer.
- An output statement displays information (in a window/console/file).
- An input statement accepts data from the user and stores that data into a variable.
- A variable is a storage location in computer memory that can be accessed and changed in the program.
Variables and Identifiers
- A variable has a name (identifier) and an associated data value (which may change during execution).
- Example: NAME is a variable; its data value could be the string "Dave".
- The name of a variable is called an identifier.
- Legal identifiers:
- NAME
- num1
- interestRate
- Num_1
- Num_2
- An identifier cannot have spaces; allowed characters are letters, numbers and underscore (_).
- Visual Logic is case-insensitive.
Hello Name Program: Strings vs Outputs
- When inputting a string, the value MUST be entered inside quotes (" ").
- However, when displaying the output string, quotes are not shown.
- Input statements are used to get data into variables.
- In Visual Logic, the input flowchart element is a parallelogram with the keyword Input followed by the variable name (e.g., Input: NAME).
- When the input statement is executed:
- The user is prompted to enter a value using the keyboard.
- The typed value is stored in the variable for later use.
- String input rules: place string values inside quotes.
- Numeric input rules:
- Contain only digits and possibly one decimal point.
- Percent symbols (%), dollar signs ($), commas (,), or any other symbols are not allowed.
Partial Weekly Paycheck Solution (Illustrative Flow)
- Flow components include:
- Begin
- Input: Hours
- Input Dialog: "Please type a value for HOURS:"
- [User enters] 40
- Input: Rate
- [Input Dialog] "Please type a value for RATE:"
- [User confirmation] (check/OK selected)
- Pay = Hours * Rate
- [Result display] 50.75
- End
- This example demonstrates the calculation and the display of a computed result.
Assignment Statements
- Assignment statements perform calculations and store the result.
- A key processing step; its flowchart shape is a rectangle.
- Structure:
- LHS: a variable on the left-hand side.
- RHS: an expression on the right-hand side.
- An equal sign (=) sits in the middle.
- When executed, the RHS expression is evaluated first, and that value is stored in the LHS variable.
- Variables hold values and have names; they are memory locations.
Weekly Paycheck: Partial Solution (Garbled Note)
- Pay will have the value: ??2030 Do you see the t t?
- This appears to be a fragment or transcription artifact from the example run.
- Flow structure:
- Begin
- Input: Hours
- Input Dialog: "Please type a value for HOURS:"
- OK
- Input: Rate
- Input Dialog: "Please type a value for RATE:"
- OK
- Pay = Hours * Rate
- Output: Pay
- End
- Example values shown in this transcript:
- Hours entry: 40
- Rate entry: 12
- Pay computation: Hours × Rate
- Result shown: 50.75
- Additional lines shown: 2030, X (these appear as part of the transcript’s sample output window rather than a fixed result)
- FormatCurrency is an intrinsic function that formats the variable inside the parentheses with:
- a leading dollar sign ($)
- a decimal point
- two places after the decimal point
- Important note: The shape of the Output shape in Visual Logic is different from Input in Visual Logic.
- Example idea: If Pay = 50.75, then FormatCurrency(Pay) would display as $50.75.
- Question raised: What would you see if you used FormatCurrency? (No explicit screenshot, but the implication is that without formatting, Pay might display as a plain number, e.g., 50.75, whereas with formatting you see a currency string like $50.75.)
- FormatCurrency – rounds off to 2 decimal places.
- The transcript emphasizes two key points about formatting:
- Formatting converts numeric values into a currency string with two decimal places.
- Without formatting, the numeric value may be shown without a dollar sign or decimal precision enhancements; with formatting, it appears as currency.
Key Takeaways and Concepts to Remember
- IO model: input → process → output is fundamental to programming and problem solving.
- Visual Logic provides a visual method to design algorithms using flowcharts and pseudocode-like syntax, but it is not itself a programming language.
- Variables and identifiers:
- Names must be valid identifiers (no spaces; letters, numbers, underscores allowed).
- Visual Logic is case-insensitive, reducing some naming errors.
- Input statements:
- Use a parallelogram with the keyword Input.
- Strings must be quoted; numeric input must be digits with optional one decimal point; avoid punctuation and symbols.
- Output statements:
- Display information; the formatting can affect how values appear (e.g., currency formatting).
- FormatCurrency is an intrinsic function to display monetary values with $ and two decimals.
- Assignment statements:
- Rectangle shape in the flowchart.
- Math expressions evaluate on the right-hand side first, then stored in the left-hand side variable.
- Real-world relevance:
- Banking/Payroll examples illustrate calculations and formatting in workplace contexts.
- A shopping cart workflow shows how IO, processing, and reporting interact in business systems.
- Practical implications:
- Handling of sensitive data (e.g., credit card numbers) requires attention to privacy and security beyond the basic Visual Logic example.
- Connections to broader concepts:
- The material complements foundational programming topics such as problem decomposition, algorithm design, and transitioning from visual representations to actual code.
- Pay calculation in a typical payroll example:
- ext{Pay} = ext{Hours} imes ext{Rate}
- Currency formatting example:
- $$ ext{FormatCurrency}( ext{Pay}) = ext{\