Top Banner

of 37

2667A Introduction to Programming ENU Companion Content

Jun 02, 2018

Download

Documents

marcoidrogo
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    1/37

    O F F I C I A L M I C R O S O F T L E A R N I N G P R O D U C T

    2667A

    Introduction to ProgrammingCompanion Content

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    2/37

    Information in this document, including URL and other Internet Web site references, is subject to change

    without notice. Unless otherwise noted, the example companies, organizations, products, domain names,

    e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with

    any real company, organization, product, domain name, e-mail address, logo, person, place or event is

    intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the

    user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in

    or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical,

    photocopying, recording, or otherwise), or for any purpose, without the express written permission of

    Microsoft Corporation.

    Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property

    rights covering subject matter in this document. Except as expressly provided in any written license

    agreement from Microsoft, the furnishing of this document does not give you any license to these

    patents, trademarks, copyrights, or other intellectual property.

    The names of manufacturers, products, or URLs are provided for informational purposes only and

    Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding

    these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a

    manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links

    may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not

    responsible for the contents of any linked site or any link contained in a linked site, or any changes or

    updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission

    received from any linked site. Microsoft is providing these links to you only as a convenience, and the

    inclusion of any link does not imply endorsement of Microsoft of the site or the products contained

    therein.

    2002 Microsoft Corporation. All rights reserved.

    Microsoft and the trademarks listed at

    http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspxare trademarks

    of the Microsoft group of companies. All other marks are property of their respective owners.

    Product Number: 2667A

    Released: 09/2002

    http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspxhttp://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspxhttp://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx
  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    3/37

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    4/37

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    5/37

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    6/37

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    7/37

    Introduction to Computer Programs 1-1

    Module 1

    Introduction to Computer Programs

    Contents:

    Question and Answers 2

    Lab: Question and Answers 5

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    8/37

    1-2 Introduction to Programming

    Question and Answers

    Practice: Identifying Program Phases

    Introduction

    In this practice, you will identify the components of each program phase.

    Identifying the program phases

    In the airline reservation application, the airline reservation clerk uses the mouse and keyboard in the

    _______ phase. In the ______ phase, the computer uses the CPU and the memory to determine flight

    availability. In the _____ phase, the monitor displays seat availability. Also, during the ______ phase, if a seat

    is available, the ticket is printed.

    Answer:

    input

    process

    outputoutput

    Practice: Calculating the Total Sales

    Identify the output and input elements

    1.

    Identify the output and input elements of the scenario.

    2. Open the InputOutput.htm file located in install_folder\Practices\Mod01\Mod01_2\Solution and

    compare your results.

    Answer: To calculate the sale value, you need output element - Total Sale Value.

    To calculate the sale value, you need the input elements - Units Sold and Unit Price.

    Identify the processes involved

    1. Identify the processes involved in the scenario.

    2. Open the Processes.htm file located in install_folder\Practices\Mod01\Mod01_2\Solution and

    compare your results.

    Answer:

    Accept Units Sold.

    Accept Unit Price.

    Multiply the number of Units Sold with the Unit Price.

    Display the Total Sale Value.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    9/37

    Introduction to Computer Programs 1-3

    Draw the Flowchart

    1.

    Draw a flowchart that represents the scenario.

    2. Open the FlowChart.gif file located in install_folder\Practices\Mod01\Mod01_2\Solution and

    compare your results.

    Answer:

    Introduction to Computer Programs

    Question: When executing a program, you are prompted to type Hello Worldand press Enter. After you

    perform the necessary steps, the message "Hello! It is a beautiful world"is displayed on the monitor.

    Identify the phases in the execution of this program.

    Answer: Input phase: Typing Hello World

    Process phase: Converting the message "Hello World" to "Hello! It is a beautiful world"

    Output phase: Displaying the message "Hello! It is a beautiful world"

    Question: What do you use to indicate a block of instructions in PseudoCompiler?

    Answer: To indicate a block of instructions in pseudocode, you use the begin-end keyword.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    10/37

    1-4 Introduction to Programming

    Question: What is the purpose of a flowchart?

    Answer:A flowchart is used to represent the algorithm of a program graphically.

    Question: Draw a flowchart to input any number, multiply it by 2, and display the result.

    Answer:

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    11/37

    Introduction to Computer Programs 1-5

    Lab: Question and Answers

    Lab 1, Exercise 1: Determining Program Phases

    Draw a flowchart to represent the program phases

    Answer:

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    12/37

    Introduction to Scripting 2-1

    Module 2

    Introduction to Scripting

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    13/37

    2-2 Introduction to Programming

    Question and Answers

    Introduction to Scripting

    Question: Define the term Internet and explain the relationship between the Internet and the Web.

    Answer: The Internet is a global network of smaller computer networks. It is the single largest

    network of computers with many available services. The Internet has grown into a vast resource

    for information and communication.

    The Web is a subset of the Internet.

    Question: What markup language would you use to create Web pages?

    Answer: HTML

    Question: List the two types of Web scripts and state the key difference between the two.

    Answer:

    Client-side scripts

    Server-side scripts

    Client-side scripts are run by the Web browser whereas server-side scripts are run on the Web

    server.

    Question: You have been asked to format a number of Word documents in a similar manner. How would

    you speed up the formatting and ensure that the documents are formatted correctly?

    Answer: Create macros to automate the formatting tasks.

    Question: How can you automate an administrative task, such as configuring the profiles of all the

    employees in your organization?

    Answer: You can create and use a Windows script to perform the task.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    14/37

    Using Data and Variables 3-1

    Module 3

    Using Data and Variables

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    15/37

    3-2 Introduction to Programming

    Question and Answers

    Practice: Identifying, Declaring, and Initializing Variables

    Draw the FlowchartAnswer:

    Write the pseudocode

    Answer:

    // Pseudocode to identify, declare, and initialize

    // variables

    begincharacter cCode

    character cName

    numeric nAgedisplay "Enter candidate code: "

    accept cCode

    display "Enter candidate name: "

    accept cNamedisplay "Enter candidate age: "

    accept nAge

    display cCodedisplay cName

    display nAge

    end

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    16/37

    Using Data and Variables 3-3

    Practice: Using Operators

    Question: Consider four variables set to the following values:

    IntA = 3

    IntB = 4

    IntC = 4

    IntD = 5

    Question: Predict the results for the comparisons listed in the following table.

    Comparison Results

    IntA < IntB Answer

    True

    IntB = IntD Answer

    False

    IntB != IntC Answer

    False

    IntB >= IntD Answer

    False

    IntC >= IntB Answer

    True

    IntB = IntC Answer

    True

    Using Data and Variables

    Question: To store values in memory and refer to those values later, what do you use?

    Answer: Variables

    Question: List the types of variables.

    Answer:

    Loop variables

    Summation variables

    Program variables

    Question: To assign meaningful names to variables, what naming conventions do you follow?

    Answer: The first letter of the variable must indicate the data type. Use nfor numeric variables

    and cfor character variables. The name of the variable should reflect the value that it is storing.

    For example, the variable nAge can be used to store a numeric value of age.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    17/37

    3-4 Introduction to Programming

    Question: You must declare all variables before you can use them so that memory is allocated before it is

    used in a program. Does the order in which you declare the variables matter?

    Answer: No. However, a variable cannot be used if it is not declared already.

    Question: What are operators?

    Answer: Operators are symbols or other characters that indicate an operation that acts upon one

    or more elements.

    Question: What are keywords?

    Answer: Keywords are reserved words in any programming language that have a special meaning.

    Question: Which data type would you use for storing country codes for telephone numbers? For

    example, 1 for United States.

    Answer: Numeric

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    18/37

    Using Program Logic 4-1

    Module 4

    Using Program Logic

    Contents:

    Question and Answers 2

    Lab: Question and Answers 5

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    19/37

    4-2 Introduction to Programming

    Question and Answers

    Practice: Printing the Product of the First 8 Even Numbers

    Write the pseudocode

    Question: Write the pseudocode to display the product of the first 8 even numbers.

    Answer: The pseudocode to display the product of the first 8 even numbers is as follows:

    // pseudocode to display the product of the first 8

    // even numbers

    begin

    numeric nNumber

    numeric nProductnumeric nCounter

    nNumber = 2

    nProduct = 1for nCounter = 1 to 8 step 1

    begin

    nProduct = nNumber * nProductnNumber = nNumber + 2

    end

    display nProductend

    Using Program Logic

    Question: Complete the following pseudocode to check the password. This code prompts the user to

    enter a user name and password. If the password is incorrect, it displays the message "Password is

    incorrect. Exiting". If the password is correct, it displays the message "Welcome to Northwind Traders".

    The password should be northwind.

    Note This pseudocode focuses on the concepts taught in this module and as a result may not comply

    with Microsoft security recommendations.

    // program to check for password

    begincharacter cUserName

    character cPassword

    display "Enter username"accept cUserName

    display "Enter password"

    accept cPassword

    if ___________________________begin

    display "Welcome to Northwind Traders"end

    _____begin

    display "Password is incorrect.... Exiting"

    endend

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    20/37

    Using Program Logic 4-3

    Answer:

    cPassword = "northwind"

    else

    Question: For applications that accept input data from the user, you must validate the data. For example,an application requires the name and test score of an employee and displays a message depending upon

    the test score. Complete the pseudocode to evaluate written test scores and display the messages based

    on the values given in the following table.

    riteria Message

    Test score greater than or equal to 40 Pass

    Test score less than 40 Fail

    Test score is negative ERROR: Score cannot be negative

    Test score is more than 100 ERROR: Score cannot be more than 100

    // Pseudocode to evaluate the written test scores and

    // display appropriate messages

    begincharacter cNamenumeric nScore

    accept cNameaccept nScoreif___________________________

    begindisplay "Pass"

    end

    else

    beginif nScore < 40 and nScore >= 0

    begindisplay "Fail"

    end

    elsebegin

    if ______________

    begindisplay "ERROR: Score cannot be more than 100"

    end

    else

    begindisplay "ERROR: Score cannot be negative"

    end

    endend

    end

    Answer:

    nScore >= 40 and nScore 100

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    21/37

    4-4 Introduction to Programming

    Question: You must run a set of statements repeatedly until the user decides to discontinue. Which loop

    do you use to solve this problem?

    Answer: When you do not know how many times that you must repeat a task, use the WHILE loop.

    Question: What are the different types of looping constructs? What are the guidelines for using each

    type?

    Answer: There are two types of looping constructs: the FOR loop and the WHILE loop. Use the FOR

    loop when the number of iterations is known beforehand. Use the WHILE loop when you do not

    know how many times a loop must execute.

    Question: What are logic errors?

    Answer: Logic errors arise because of incorrect implementation of business rules or incorrect

    program logic. They may cause an abnormal termination of the program or cause the program to

    return abnormal results.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    22/37

    Using Program Logic 4-5

    Lab: Question and Answers

    Draw the Flowchart

    Answer:

    Implement the solution

    Question: Write the pseudocode.

    Answer:

    // Pseudocode to select candidates based on interview scores

    begin

    character cCode

    character cNamenumeric nRound1

    numeric nRound2

    display "Enter candidate code"accept cCode

    display "Enter candidate name"

    accept cName

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    23/37

    4-6 Introduction to Programming

    display "Enter Round 1 interview score"

    accept nRound1

    if nRound1 < 1 or nRound1 > 10begindisplay "ERROR: Round 1 score has to be in the range of 1 to 10"

    end

    elsebegin

    if nRound1 < 6begin

    display "Round 1 score must be greater than 5. Send rejection letter."

    endelse

    begin

    display "Candidate is eligible for Round 2 interview"display "Enter Round 2 interview score"

    accept nRound2

    if nRound2 < 1 or nRound2 > 10begin

    display "ERROR: Round 2 score must be in the range of 1 to 10"

    end

    else begin

    if nRound2 > 7

    begindisplay " Interviews completed successfully. Send offer to

    candidate."

    endelse

    begin

    display "Round 2 score must be greater than 7. Sendrejection letter."

    end

    endend

    end

    end

    Note The solution code for this exercise is provided in the Mod4_Ex1.txt file in the

    install_folder\Labfiles\Lab04\Solution folder.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    24/37

    Using Procedures and Functions 5-1

    Module 5

    Using Procedures and Functions

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    25/37

    5-2 Introduction to Programming

    Question and Answers

    Review Answers

    Using Procedures and Functions

    Question: What are procedures?

    Answer: Procedures are the executable code statements in a program. The statements in a

    procedure are enclosed by a declaration statement and an End statement.

    Question: What are the different types of procedures?

    Answer: There are three types of procedures:

    Sub procedure

    Function procedure

    Property procedure

    Question: What is the main difference between a Subprocedure and a Functionprocedure?

    Answer: A Function procedure has a return type and always returns a value. A Sub procedure does

    not have any return type and does not return a value.

    Question: Give examples of functions.

    Answer:

    String function

    Len function

    Left function

    Trim function

    Question: The Functionprocedure sends back a value to the calling program. What is that value called?

    Answer: Return value

    Question: What is the syntax for a Subprocedure?

    Answer:

    [accessibility] Sub subname[(argumentlist)]

    ' Statements of the Sub procedure go here

    End Sub

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    26/37

    Introduction to Developing a User Interface 6-1

    Module 6

    Introduction to Developing a User Interface

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    27/37

    6-2 Introduction to Programming

    Question and Answers

    Review Answers

    Introduction to Developing a User Interface

    Question: You are developing a large application that is to be used by advanced users. You have been

    told to keep the application simple. However, because the users are experienced, user-friendliness is not

    particularly important. Would you design a command-based interface or graphical user interface?

    Answer: Command-based interface.

    Question: List three key features of a good interface.

    Answer: Intuitive design, ease of navigation, and input validation.

    Question: How do you build a user interface for a Windows-based application?

    Answer: Add controls from the Toolbox to the Windows Forms Designer.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    28/37

    Introduction to Working with Data 7-1

    Module 7

    Introduction to Working with Data

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    29/37

    7-2 Introduction to Programming

    Question and Answers

    Practice: Representing Data as Tables

    Exercise 1

    Identify the entity

    Answer: In this situation, the entity is Employee.

    Exercise 2

    In this exercise, you will identify the attributes for the entity that you have identified.

    Identify the attributes

    Answer:

    In this situation, the attributes are:

    EmployeeName

    Address

    City

    Zip

    Country

    Phone

    Qualification

    BirthDate

    Sex

    Designation

    EmailId

    Dept

    Region

    Photograph

    JoiningDate

    ResignationDate

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    30/37

    Introduction to Working with Data 7-3

    Exercise 3

    In this exercise, you will represent the entity and its attributes in the form of a table.

    Represent the entity and its attributes in a table structure

    Question: Create a table structure to represent the entity and its attributes. List all the column

    headings for the table in a column.

    Answer:

    mployeeName

    Address

    City

    Zip

    Country

    Phone

    Qualification

    BirthDate

    Sex

    Designation

    EmailID

    Dept

    Region

    Photograph

    JoiningDate

    ResignationDate

    Introduction to Working with Data

    Question: What is a database?

    Answer: A database is a collection of data. A computer system uses a database to store and

    manage data.

    Question: What is a relationship?

    Answer: A relationship describes the connection between a pair of logically related entities.

    Question: What is a candidate key?

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    31/37

    7-4 Introduction to Programming

    Answer: A candidate key is an attribute or set of attributes that uniquely identifies a row in a data

    table. A candidate key is also called a surrogate key.

    Question: Define XML.

    Answer:XML is a markup syntax that defines the structure of data in an open and self-describing

    manner. XML enables you to transfer data easily over a network and ensure that the data isprocessed consistently by the applications that use it. Because XML is used to describe and

    structure information, XML is like a data-description language. You can use XML to describe data

    components, records, and other complex data structures, such as purchase orders, catalogs, and

    documents.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    32/37

    Programming Approaches 8-1

    Module 8

    Programming Approaches

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    33/37

    8-2 Introduction to Programming

    Question and Answers

    Review Answers

    Programming Approaches

    Question: What is the limitation of the procedural approach to programming?

    Answer: Applications developed by using the procedural approach are interdependent and not

    resilient to change. In addition, you cannot reuse the procedures of one application in another

    application.

    Question: What are three components of an object?

    Answer: An object has:

    State

    Behavior Identity

    Question: What is the relationship between objects and classes?

    Answer: Objects are instances of classes. An object has the attributes and behavior of its class.

    Question: What is inheritance?

    Answer: Inheritance is a feature of object-oriented programming. You can generalize the

    attributes and behavior of objects and create a parent class. You can then create subclasses that

    inherit the attributes and behavior of the parent class and have their own specific attributes and

    behavior as well.

    Question: How are object-oriented applications resilient to change?

    Answer: In object-oriented applications, you do not need to change the entire application when

    you change part of the application. You can update a specific class or add more classes to the

    application.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    34/37

    Introduction to the Software Development Process 9-1

    Module 9

    Introduction to the Software Development Process

    Contents:

    Question and Answers 2

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    35/37

    9-2 Introduction to Programming

    Question and Answers

    Review Answers

    Introduction to the Software Development Process

    Question: What are the primary design goals of UML?

    Answer: The primary design goals of UML are:

    To provide a simple and ready-to-use expressive modeling language that enables the user

    to visualize, develop, and exchange meaningful models of a system

    To integrate best practices of other modeling approachesTo help all software system

    stakeholders understand how the system will work and what options are available

    To provide a formal basis for understanding the modeling language

    To support high-level development concepts such as components, collaborations,

    frameworks and patterns

    Question: What are the features of UML?

    Answer: The features of UML are:

    Simple, extensible, and expressive visual modeling language

    A set of notations and rules for modeling software systems of varying complexities

    The creation of simple, well documented, and easy to understand software models

    Language and platform independence

    Question: Which UML diagram represents a set of classes, and the messages sent and received by thoseclasses?

    Answer: Collaboration diagram

    Question: What are actors?

    Answer: Actors are elements that are outside the system. They are also called the external entities

    of a system. External entities that do not interact directly with the system are not actors.

    Question: List the categories of actors.

    Answer: There are four categories of actors: principal actors, secondary actors, external hardware,

    and other systems

    Question: What is a use case?

    Answer: A use case is a set of transactions that the system performs when an actor initiates an

    event or action. Use cases represent all the possible events that can occur in all possible scenarios.

    They represent all interactions that can take place between an actor and the system.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    36/37

    Introduction to the Software Development Process 9-3

    Question: What is the purpose of a use-case diagram?

    Answer: The purpose of the use-case diagram is to establish the scope of the project and provide

    structure for the system. The use-case diagram describes the behavior of the system from the

    point of view of its end users and developers. It also describes their expectations of the system.

    Question: How do you represent use cases in a use-case diagram?

    Answer: You represent use cases as ellipses in a use-case diagram.

    Question: How do you identify the behavior of a class?

    Answer: To identify the behavior of a class, you study the use case to determine the actions that

    the class will perform.

    Question: How do you identify the attributes of a class?

    Answer: To identify the attributes of a class, you study the use case to determine the

    characteristics of the class.

    Question: How do you represent a class name in a class diagram?

    Answer: A class name is depicted in the top section of a rectangle. The class name is always

    centered and in bold typeface.

    Question: What are links in an object diagram?

    Answer: Links are instances of associations between classes. Links depict the relationship between

    two objects in a system at any instant.

    Question: Do you always need to create three sections in the rectangle to represent an object in anobject diagram?

    Answer: No. Display the information relevant to current scenario for every object. If there are no

    relevant behavior names for an object, you need not include them in the object diagram.

  • 8/10/2019 2667A Introduction to Programming ENU Companion Content

    37/37

    Introduction to Programming 1-1

    Send Us Your FeedbackYou can search the Microsoft Knowledge Base for known issues atMicrosoft Help and Supportbefore

    submitting feedback. Search using either the course number and revision, or the course title.

    Note Not all training products will have a Knowledge Base article if that is the case, please ask

    your instructor whether or not there are existing error log entries.

    Courseware Feedback

    Send all courseware feedback [email protected] truly appreciate your time and effort.

    We review every e-mail received and forward the information on to the appropriate team. Unfortunately,

    because of volume, we are unable to provide a response but we may use your feedback to improve your

    future experience with Microsoft Learning products.

    Reporting Errors

    When providing feedback, include the training product name and number in the subject line of your e-

    mail. When you provide comments or report bugs, please include the following:

    Document

    Page number or location

    Complete description of the error or suggested change

    Please provide any details that are necessary to help us verify the issue.

    Important All errors and suggestions are evaluated, but only those that are validated are addedto the product Knowledge Base article.

    http://go.microsoft.com/fwlink/?LinkId=64183http://go.microsoft.com/fwlink/?LinkId=64183http://go.microsoft.com/fwlink/?LinkId=64183mailto:[email protected]:[email protected]:[email protected]:[email protected]://go.microsoft.com/fwlink/?LinkId=64183