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
-
chapter 10 Student: ___________________________________________________________________________ 1. Antidiuretic hormone is released by: A.anterior lobe of the pituitary B.posterior lobe of the pituitary C.hypothalamus D.adrenal glands 2.…
- 3492 Words
- 14 Pages
Powerful Essays -
5. This chapter describes the concepts behind how a CPU reads the contents from RAM. Which of the following is true about the process of read data. As described in the chapter?…
- 1315 Words
- 6 Pages
Good Essays -
It was interesting to learn that they considered homosexual sex “perverted.” I had always been under the impression that it…
- 436 Words
- 2 Pages
Good Essays -
Open the control panel, click on programs then click on “uninstall a program”, find the program causing you a problem, right click on…
- 324 Words
- 2 Pages
Satisfactory Essays -
13) For each of the following 6-bit operations, calculate the values of the C, Z, V, and N flags in the ARM.…
- 438 Words
- 3 Pages
Satisfactory Essays -
3) The first draft of the human genome was first published in the Journal Nature. Knowing all the genes in humans may have profound affects on which areas in the future?…
- 1835 Words
- 8 Pages
Good Essays -
11. In what way did sixteenth-century Europeans benefit from trade between the Americas and Europe?…
- 390 Words
- 3 Pages
Satisfactory Essays -
4.) Write assignment statements that perform the following operations with the variables a, b, and c:…
- 470 Words
- 3 Pages
Satisfactory Essays -
4) A local variable is declared inside the module only. Only the statements inside the module can access it.…
- 1580 Words
- 11 Pages
Better Essays -
1. The state of Florida is amongst 16 other states that selects judges through the method “appointment-retention election”. A method in which a proposing group shows names to the governor, who then makes the appointment; appointees need to win a retention vote in the next election. It is not necessarily a good system because the selection is placed in the hands of the judges or attorneys who comprise the nominating committee and the governor, with only a impression of voter input. Reorganizers argue that the plan eliminate judges from politics and saves the electorate the problem of voting on judicial candidates when they know little about their professional qualifications.…
- 318 Words
- 2 Pages
Satisfactory Essays -
For instance, some people might think that a professional mathematics teacher is somebody that wears glasses and is stereotypical nerd like demeanor; mean while others might visualize a very uptight and strictly teachers that’s likes their student to solve a problem the same way they show them instead of finding a shortcut and is easier for their students to understand the concept and how to solve it. When I think about a very uptight and strict mathematics teacher, I picture someone that teaches on a college level like a college professor. Some may say that a very uptight and strictly mathematics teacher is stereotypical military general like demeanor. In the first week, we discussed the NCTM mathematical standards and processes. I think that in the first week of class the NCTM mathematical standards and processes is relevant to the characteristics of a professional mathematics teacher is that because at least three out of six NCTM principles which are curriculum, teaching, and assessment are part of the professional mathematics teacher characteristics. For example, curriculum is more than a collection of activities: it must be coherent focused on important mathematics, and well-articulated across the grades, teaching requires understanding what students know and need to learn and then challenging and supporting them to learn it well, and assessment should support the learning of mathematics and furnish useful information to both teachers and students. In week two, the concept Algebraic Thinking and Problem Solving is where a teacher can show their class how to use numerical patterns, relations, and functions to solve problems. In week three and four, Number Theory and Rational Numbers and Rational Numbers and Applications is where teachers can predict operational outcomes, apply properties of integers, make reasonable estimates, apply number theory to…
- 792 Words
- 4 Pages
Satisfactory Essays -
5.) When an argument is passed by reference, the module can modify the argument in the…
- 1236 Words
- 9 Pages
Satisfactory Essays -
| CHECKS THE CONDITION FIRST AND THEN THE EXECUTION BEGINS. IT IS KNOWN AS ENTRY CONTROL LOOP…
- 7765 Words
- 32 Pages
Good Essays -
With what do you replace the ???? to make the function shown above return the correct answer?…
- 604 Words
- 6 Pages
Good Essays -
In the most common case, call-by-value, a parameter acts within the subroutine as a local (isolated) copy of the argument, but in other cases, e.g. call-by-reference, the argument supplied by the caller can be affected by actions within the called subroutine (as discussed in evaluation strategy).…
- 974 Words
- 4 Pages
Good Essays