Top-Rated Free Essay
Preview

PT1420 E1 Unit2 Lab2 Herrera Javier

Satisfactory Essays
777 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
PT1420 E1 Unit2 Lab2 Herrera Javier
Lab 2: Input, Processing, and Output
This lab accompanies Chapter 2 (pp.29-55) of Starting Out with Programming Logic & Design.

Name: Javier Herrera
Lab 2.1 – Pseudocode

This lab requires you to focus on variable assignment and calculations. Read the following program prior to completing the lab.

Write a program that will calculate the cost of installing fiber optic cable at a cost of .87 per ft for a company. Your program should display the company name and the total cost.

Step 1: Examine the following algorithm as a base for how the program should flow. (Reference: Designing a Program, page 31).

1. Display a welcome message for your program.
2. Get the company name.
3. Get the number of feet of fiber optic to be installed.
4. Multiply the total cost as the number of feet times .87.
5. Display the calculated information and company name.

Step 2: Think of good variable names for the following pieces of data that will need to be stored with in this program.

Purpose of Variable
Variable Name
Stores the cost of fiber fiberCost Stores the company name compName Stores the number of feet to be installed feetIns Stores the calculated cost of installed fiber calcCost Step 3: Complete the following pseudocode based on the algorithm and the variables you declared above.

Display “Welcome to the Fiber Optic Calculator Program”
Set fiberCost = 0.87
Display “What is the company name?”
Input compName
Display “How many feet of fiber will be installed?”
Input feetIns
Set calcCost=feetIns*fiberCost
Display “For the company ”,compName ,”the total cost will be $”calcCost

Lab 2.2 – Flowchart

This lab requires you to think about the steps that take place in a program by designing a flowchart. While designing flowcharts can be done with paper and pencil, one mistake often requires a lot of erasing. Therefore, a flowcharting application such as Raptor or Visio should be used. This lab will give you a brief overview of Raptor. Read the following program prior to completing the lab.

Write a program that will calculate the cost of installing fiber optic cable at a cost of .87 per ft for a company. Your program should display the company name and the total cost.

Step 1: Launch Raptor or Visio and convert your pseudocode from Lab 2-1 into a flowchart. Depending on what application you are using, select one of the following skeletons to get started. Once you double click on them to open, do a Save As to save it to your workspace. Watch the help video 2.2 for instructions on how to input, calculate, and output using both applications.

Raptor skeleton Visio skeleton

Step 2: The final step is to insert your finished flowchart in the space below. Inside Raptor, select File and the Print to Clipboard from the menu. If you are using Visio, select Edit, then Select All, then Edit and Copy. In the space below, select Edit and Paste. Lab 2.3 – Visual Basic

This lab will focus how to assign variables and process calculations in Visual Basic.

Step 1: Create a new Visual Basic Console Application and save it to your workspace location.

Step 2: The first part of this program will convert the pseudocode from page 44 to Visual Basic. Under Sub Main()add the following line of code.

Console.WriteLine("This part of the program will code Program 2-6 from page 44")

You can also use Console.Write() if you want the cursor to stay on the same line as your output.

Step 3: Following the steps on page 44, next declare dollars such as:

Dim dollars As Double = 2.75 Step 4: Using Console.WriteLine() code step 2 from Program 2-6 such as:

Console.WriteLine("I have " & dollars & " in my account.")

Notice the & are used in Visual Basic and , are used in pseudocode.

Step 5: Reset dollars to 99.95 by adding the following:

dollars = 99.95

Step 6: Convert step 4 from page 44 to display what is now in the account. You can follow the Visual Basic syntax from Step 4 of this lab.

Step 7: At the very bottom before End Sub add the following lines so that your program will Pause and you can see your output.

Console.WriteLine("Press any key to continue") Console.ReadLine()

Step 8: Save and run your program so that works without errors. Copy and paste your Visual Basic code below.

Module Module1

Sub Main() Console.WriteLine("This part of the program will code Program 2-6 from page 44") Dim dollars As Double = 2.75 Console.WriteLine("I have " & dollars & " in my account.") dollars = 99.95 Console.WriteLine("I have " & dollars & " in my account.") Console.WriteLine("Press any key to continue") Console.ReadLine()

End Sub

End Module

You May Also Find These Documents Helpful