Unit 2 Assignment 1: Homework (material from Chapter 2of your text book)
1.) What is pseudocode? A.) Pseudocode is when you pre write a program in your own type of language to lay it out
2.) Computer programs typically perform what 3 steps. A.)Input, Process, Output.
3.) What 2 things must you normally specify in a variable declaration. A.)Type, Identifier.
4.) Write assignment statements that perform the following operations with the variables a, b, and c:
a. Adds 2 to a and stores the result in b// Ans.)B = 2 + A
b. Multiples b times 4 and stores the result in a //Ans.)A = B * 4
c. Divides a by 3.14 and stores the result in b//Ans.)B = A / 3.14
d. Subtracts 8 from b and stores the result in a//Ans.) A = B – 8
5.) Write the pseudocode for a program that will determine the average miles per gallon a car gets. (Inputs should be miles driven and gallons of gas used)
Ans.) Input: How many miles have you driven?, How many gallons of gas did you have?
Process: Divide miles by gas to get average.
Output: Display average miles per gallon.
*****************************************************************
Unit 2 Labs
Problem:
Write a program that will calculate the cost of installing fiber optic cable at a cost of .87 per foot for a company. Your program should display the company name, number of feet installed, and the total cost for the installation.
1.) 2.1: Pseudocode
Variable Table
Purpose of Variable
Variable Name
Stores the cost of fiber
.87
Stores the company name
Business
Stores number of feet to be installed
Installed Feet
Stores calculated cost of installed fiber
Total Cost
Pseudocode:
Display “Welcome to the Fiber Optic Calculator Program”
Set fiberCost = 0.87
Display “What is the Company Name?”
Input Business
Display “How many feet of fiber will be installed?”
Input 10
Set Cost
Display “Company Name: “, Business
Display “Feet of cable