FOR LOGIC PRO ONLY

1. (TCO 1) What is the first step in software development?

(Points : 5)

Develop the logical solution

Understand the problem

Plan/design the logic

Translate into code

Question 2. 2. (TCO 2) Memory locations that are used to store data used in a program are called _____.

(Points : 5)

data

variables

software

instructions

Question 3. 3. (TCO 3) Which symbol in a flowchart would be used by a developer to represent a calculation (process)?

(Points : 5)

Rectangle

Diamond

Parallelogram

Lozenge

Question 4. 4. (TCO 2) You are using dollar amounts in an algorithm. Which data type would you assign to the cost variable?

(Points : 5)

Integer

Real

String

Any of the above

Question 5. 5. (TCO 3) Which tool is used by developers to depict the relationship between modules?

(Points : 5)

Desk-checking

Flowcharts

Pseudocode

Hierarchy charts

Question 6. 6. (TCO 2) When an expression includes relational, logical, and arithmetic operators, which type of operator is evaluated first?

(Points : 5)

Arithmetic

Relational

Logical

It depends on the expression.

Question 7. 7. (TCOs 2 and 7) Which one of the following is not a valid assignment statement in a program?

(Points : 5)

total = total + 1

counter = counter + 10

tax = amount * .10

None of the above

Question 8. 8. (TCO 2) Which value will be contained in the variable x after the following statement is executed?

x = 10 + 8 / 2 * 3

(Points : 5)

3

45

22

27

Question 9. 9. (TCO 2) Which statement indicates that the variable rep is being used as an accumulator?

(Points : 5)

rep = 0

rep = rep + 1

rep = rep + x

rep = rep + 10

Question 10. 10. (TCO 4) For the following expression to be true, _____.

condition1 AND condition2

(Points : 5)

both conditions must be false

both conditions must be true

either condition can be false

either condition can be true

Question 11. 11. (TCOs 2, 7, and 8) Review the partial pseudocode below. Which is the correct math expression to complete the algorithm and calculate 25% of a cost?

Prompt “Enter total cost: “

Input cost

Set _____

Display “25% of the cost is: “ + total

(Points : 5)

total = cost

total = cost * 0.25

total = cost / 0.25

total = cost * 25%

Question 12. 12. (TCOs 3, 4, and 8) Review the pseudocode below. Which will be displayed when this algorithm executes?

Set x = 19

If ((x > = 10) AND (x < 20)) then

Display “the IF path executes”

Else

Display “the ELSE path executes”

EndIf

(Points : 5)

the IF path executes

the ELSE path executes

20

(x >= 10) AND (x < 20)

Question 13. 13. (TCOs 3, 4, and 8) Which value gets displayed for the variable X?

Set A = 5

Set B = 20

Set C = 15

If (B > 15) AND (A = 5) AND (C <= 15) then

Set X = 1

Else

Set X = 0

EndIf

Display X

(Points : 5)

5

0

10

1

1. (TCOs 2,4, 5, and 8) Write a program to input a purchase amount and calculate the sales tax and total due. The sales tax depends on the county identifying code. Counties with a number less than 15 have a 5% sales tax. The 16–30 codes have a sales tax of 6%. Codes above 30 have a sales tax of 7%. The purchase amount and county code are entered by the user. Use a loop to validate that the county code is between 8 and 40. Display the amount of the sales tax and the total.

(Points : 20)

Question 2. 2. (TCOs 3, 4, and 8) In the following pseudocode, which raise will an employee in Department 3 receive?

If department < 3 then

Set raise = 25

Else

If department < 5 then

Set raise = 50

Else

Set raise = 75

EndIf

EndIf

(Points : 5)

25

50

75

0

Question 3. 3. (TCOs 3 and 4) Which of the selection structures determine whether the user enters a number within a range of 5 and 15?

(Points : 5)

If commission > 15

If commission <= 15

If (commission < 5) || (commission >15)

If (commission >=5) & (commission <= 15)

Question 4. 4. (TCOs 3, 4, and 8) Which value gets displayed for the variable Z?

Set balance = 800

Set stateCode = 6

Set creditCode = 6

If (balance > 800) OR (stateCode > 6) OR (creditCode > 7) then

Set Z = 1

Else

Set Z = 3

EndIf

Display Z

(Points : 5)

1

3

6

7

Question 5. 5. (TCO 5) The variable used in the expression controlling the loop is known as the _____.

(Points : 5)

loop control variable

loop iterations

loop expression variable

loop body

Question 6. 6. (TCO 5) A FOR loop is considered what type of loop?

(Points : 5)

A counted loop

A post-test loop

An event-controlled loop

A selection structure

Question 7. 7. (TCO 5) In the following code, how many times will the loop body be executed?

intnum;

for (num = 0; num <= 5;num++ )

{

Console.WriteLine(num);

}

(Points : 5)

0

1

5

6

Question 8. 8. (TCOs 3, 5, and 8) In the following code, how many times will the loop body be executed?

int x=1;

while(x!=6)

{

Console.WriteLine(x);

x = x + 1;

}

(Points : 5)

0

1

5

6

Question 9. 9. (TCO 6) All elements of an array must have the same _____.

(Points : 5)

subscript

index

data type

value

Question 10. 10. (TCO 6) Which one of the following correctly declares an array of five integers in C#?

(Points : 5)

int[] num = new int[4];

int[] num = new int[5];

intnum = int[5];

intnum =5;

Question 11. 11. (TCOs 5 and 6) Which statement will be placed in the loop body to double each value of the array specified in the code below?

int[] nums = new int[5];

for (int index = 0; index <5; index++)

{

What stastement goes here?

}

(Points : 5)

nums = nums * 2

nums[index] * 2

nums[index] = nums[index] *2;

None of the above

Question 12. 12. (TCO 6) A zero-based array named testGrades has been declared and loaded with the values 85, 90, 72, 95, 98, 81, and 79. Which value(s) will be stored in the array element testGrades[4]?

(Points : 5)

72

95

98

72, 95, 98

Question 13. 13. (TCOs 7 and 8) Creating a flowchart and desk-checking it before coding helps to eliminate which type of error?

(Points : 5)

Syntax error

Runtime error

Logic error

Out-of-bounds error

Question 14. 14. (TCOs 3 and 8) Which of the following is not an advantage of modular design?

(Points : 5)

It increases complexity.

Modules can be reused.

It is easier to work in teams — different people completing different modules.

All of the above are advantages.

Write a C# loop that counts down from 100 to 10 by 5s.

PART 1 (10 points): A furniture store is having a customer appreciation sale. Depending on the total dollars purchased, the customer could receive a discount on his or her total purchases. You are to develop pseudocode or C# code that will obtain the total dollars purchased from the user, determine the discount percentage, and display the total amount due. When the purchases are more than $2,000, the discount is 12%. When the purchases are $2,000 or less, the discount is 7%.

PART 2 (10 points): Create a function called calcDiscount that will calculate and return the discount amount. Write the function and call it in the code.

Review the following scenario and complete the design.

Scenario

Professor Higgins has asked you to design the logic that will be used to calculate final class averages and grades for his students. His grading algorithm is as follows.

Exam average: 50%

Quiz average: 25%

Lab average: 25%

< Professor Higgins has 30 students in his class. For each student, Professor Higgins will enter the students’s name and store into a “names” array. Then input the value for each of the averages (exam, quiz, and lab). Then using the weighting above the program will calculate the final student class average and store each student’s final average into an array. The program will then determine the letter grade for each student using the following criteria.

90–100: A

80–89: B

70–79 C

60–69 D

Less than 59 F

When the student’s final grade is determined, the final grade will be stored in a third “grade” array.

After all data have been input and calculations done, display the final output using the three arrays as a Grade Report with headings of NAME, AVERAGE, and GRADE.

· Display the name, final average, and grade for all the students.

· Calculate and display the total class average (total of all individual student averages / number in class).

Write a program using C#, prompt the user for the appropriate input, and display the output as described above. You may assume all data are valid. Provide a program introduction message that tells the user how to use the program.