Top-Rated Free Essay
Preview

PT1420 Chapter 3 Review

Satisfactory Essays
1062 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
PT1420 Chapter 3 Review
PT1420
Multiple Choice
1. C: Module
2. A: Code reuse
3. D: Header
4. B: Call
5. C: return
6. A: Top-down design
7. D: Hierarchy chart
8. B: local variable
9. C: Scope
10. A: argument
11. B: parameter
12. C: passing an argument by value
13. A: passing an argument by reference
14. D: global variable
15. B: Global
True or False
1. F
2. T
3. F
4. F
5. F
6. T
7. F
8. T
9. F
10. F
11. T
12. F
Short Answers
1. It cuts down on duped code, by reusing what was already written
2. Header and body
3. Returns back to the point from where it was sidetracked
4. a variable declared inside a module, and is only applied in that module
5. begins when you declare and ends with the end of the module
6. by value is just a copy, and by reference passes into special modification
7. because it could be a variable conflict, the global variables are inherited throughout the whole program, so it very well could conflict with others
3. Write assignment statements that perform the following operations with the variables a, b, and c. * Adds 2 to a and stores the result in b * Set b= 2 +a * Multiplies b times 4 and stores the result in a * set a= b*4 * Divides a by 3.14 and stores the result in b * set b= 3.14/b * Subtracts 8 from b and stored the result in a * set a= b-8

4. Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2. What value will be stored in result in each of the following statements? * set result= x+y= 4+8 * set result=z*2= 2*2 * set result= y/x= 8/4 * set result= y-z= 8-2
5. Write a pseudocode statement that declares the variable cost so it can hold real numbers. * Floating-point variable cost.
6. Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0. * Declare Real price=99.95 * Display "the original price." * Input item original price * Display "price"
7. Write a pseudocode statement that assigns the value 27 to the variable count. * Count:=27
8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. * Declare Integer total=0 * Set total=10+14
9. Declare Integer downPayment
Declare Integer Total
Declare Integer Due
10. Dim subtotal As Double = 0 totalfee = subtotal * 0.15
Progamming
1. Module Module1

Sub Main() Dim kilTrav As Double = 0 Dim miles As Double = 0 Call convMile(kilTrav, miles) Console.ReadLine()

End Sub

Sub convMile(ByRef kilTrav As Double, ByRef miles As Double) Console.WriteLine("Input Kilometers traveled") kilTrav = Console.ReadLine() miles = kilTrav * 0.6214 Console.WriteLine("Your miles traveled are " & miles) End Sub

End Module
2.)
3.) Module Module1

Sub Main() Dim repCost As Double = 0 Dim insurance As Double = 0 Call insSub(repCost, insurance) Console.WriteLine("Press enter to continue...") Console.ReadLine()

End Sub Sub insSub(ByRef repCost As Double, ByRef insurance As Double) Console.Write("Input cost to replace home ") repCost = Console.ReadLine() insurance = repCost * 0.8 Console.WriteLine(" You should get a policy that covers at least " & insurance & "$ to be safe.")

End Sub
End Module

4.) Module Module1

Sub Main() Dim tireCost As Double = 0 Dim oilCost As Double = 0 Dim paymentCost As Double = 0 Dim insCost As Double = 0 Dim gasCost As Double = 0 Dim maintenance As Double = 0 Dim monthTotal As Double = 0 Dim yearTotal As Double = 0 Call monthlyBill(tireCost, oilCost, paymentCost, insCost, gasCost, maintenance, monthTotal) Call yearlyBill(monthTotal, yearTotal) Console.WriteLine("Press enter to continue...") Console.ReadLine() End Sub

Sub monthlyBill(ByRef tireCost As Double, ByRef oilCost As Double, ByRef paymentCost As Double, ByRef insCost As Double, ByRef gasCost As Double, ByRef maintenance As Double, ByRef monthTotal As Double) Console.WriteLine("input cost of tires per month") tireCost = Console.ReadLine Console.WriteLine("input cost of oil per month") oilCost = Console.ReadLine Console.WriteLine("input payment per month") paymentCost = Console.ReadLine Console.WriteLine("input insurance cost per month") insCost = Console.ReadLine Console.WriteLine("input cost of gas per month") gasCost = Console.ReadLine Console.WriteLine("input cost of maintenance per month") maintenance = Console.ReadLine monthTotal = tireCost + oilCost + paymentCost + insCost + gasCost + maintenance Console.WriteLine(" Your monthly cost for this car is " & monthTotal)

End Sub

Sub yearlyBill(ByRef monthTotal As Double, ByRef yearTotal As Double) yearTotal = monthTotal * 12 Console.WriteLine(" Your yearly cost for this car will be " & yearTotal) End Sub

End Module

5.) Module Module1

Sub Main() Dim actCost As Double = 0 Dim assesCost As Double = 0 Dim propTax As Double = 0 Call assess(actCost, assesCost) Call prop(assesCost, propTax) Console.WriteLine("press enter to continue...") Console.ReadLine()

End Sub

Sub assess(ByRef actCost As Double, ByRef assesCost As Double) Console.WriteLine(" input actual cost of your property") actCost = Console.ReadLine assesCost = actCost * 0.6 Console.WriteLine("The assessment cost of your property is " & assesCost & "$") End Sub

Sub prop(ByRef assesCost As Double, ByRef propTax As Double) propTax = assesCost / 100 * 0.64 Console.WriteLine("The property tax cost of your property is " & propTax & "$") End Sub

End Module

6.) Sub Main() Dim weight As Double = 0 Dim height As Double = 0 Dim bmi As Double = 0 Call calc(weight, height, bmi) Console.WriteLine("press enter to continue...") Console.ReadLine() End Sub

Sub calc(ByRef weight As Double, ByRef height As Double, ByRef bmi As Double) Console.WriteLine("input weight") weight = Console.ReadLine Console.WriteLine("input height in decimal form") height = Console.ReadLine() bmi = (weight * (703 / (height ^ 2))) Console.WriteLine(" your BMI is " & bmi) End Sub
7.) Module Module1

Sub Main() Dim fatGrams As Double = 0 Dim carbGrams As Double = 0 Dim carbCal As Double = 0 Dim fatCal As Double = 0 Call fatcalc(fatCal, fatGrams) Call carbcalc(carbGrams, carbCal) Console.WriteLine("press enter to continue...") Console.ReadLine()

End Sub

Sub fatcalc(ByRef fatGrams As Double, ByRef fatCal As Double) Console.WriteLine("input grams of fat consumed for today") fatGrams = Console.ReadLine() fatCal = fatGrams * 9 Console.WriteLine("You have consumed " & fatCal & " Calories from fats") End Sub

Sub carbcalc(ByRef carbCal As Double, ByRef carbGrams As Double) Console.WriteLine("input grans of carbs consumed for today") carbGrams = Console.ReadLine() carbCal = carbGrams * 4 Console.WriteLine(" You have consumed " & carbCal & " Calories from fats") End Sub
End Module
8.) Module Module1

Sub Main() Dim seatA As Integer = 0 Dim seatB As Integer = 0 Dim seatC As Integer = 0 Dim saleTotal As Integer = 0 Call seats(seatA, seatB, seatC, saleTotal) Console.WriteLine("Press enter to continue...") Console.ReadLine()

End Sub

Sub seats(ByRef seatA As Integer, ByRef seatB As Integer, ByRef seatC As Integer, ByRef saleTotal As Integer) Console.WriteLine(" Input how many section A seats were sold.") seatA = Console.ReadLine * 15 Console.WriteLine(" Input how many section B seats were sold.") seatB = Console.ReadLine * 12 Console.WriteLine(" Input how many section C seats were sold.") seatC = Console.ReadLine * 9 saleTotal = seatA + seatB + seatC Console.WriteLine("Total sales for all sections is " & saleTotal)

End Sub

End Module

You May Also Find These Documents Helpful

Related Topics