CMIS 130 Final Exam

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

symbol used to concatenate items in the print line in VB

&

if age 75, what is the value of Discount after the following code executes? If Age < 40 And Age > 65 Then Discount = .25 Else Discount = 0 End If

0

If TotalInMinutes is 130, what is the value in DownloadMinutes after the following code executes? If TotalInMinutes >= 60 Then DownloadHours = TotalInMinutes \ 60 DownloadMinutes = TotalInMinutes MOD 60 Else DownloadHours = 0 DownloadMinutes = TotalInMinutes End If

10

Which of the following is NOT a valid variable name when considering the rules for naming variables in Java? NAME 10count $amount lastName

10count

Given the following code, how many times does the loop execute? int sum = 0; int x = 0; while(x <= 10) { sum += x; x++; }

11

how many times does the loop execute? Dim NumberCounter As Integer Const NUM_LOOPS As Integer = 10 For NumberCounter = 0 To NUM_LOOPS ByTen = NumberCounter * 10 System.Console.WriteLine(NumberCounter & ByTen) Next NumberCounter

11

Given the following code, what is the value of Sum after the loop completes? Dim Sum As Integer = 0 Dim Count As Integer For Count = 3 To 5 Sum += Count Next Count

12

If your method contains the following Java statements: int number1 = 17; int number2 = 3; int number3 = 15; number3 = number1 / number2; What is the value in number3 after the code executes?

15

In the following code, what's the value of charge? double charge = 10.0; int numChars = 8; if (numChars > 15) charge += (numChars - 15) * 4.00; else if (numChars > 5) charge += (numChars - 5) * 2.00;

16

how many times will "Hello" print in the following loop? Dim Count As Integer For Count = 1 To 5 System.Console.WriteLine("Hello") Count = Count +1 Next Count

3

what value does someVals[1] have? num someVals[5] = 1,3,5,7,9

3

how many times does the following loop execute? For Counter = 1 To 7 System.Console.WriteLine("Hello") Counter += 1 Next Counter

4

Given the following code, what is the value of sum after the loop completes? int sum = 0; int x; for(x = 5; x <= 10; x++) { sum += x; }

45

Given the following pseudocode, how many times will the loop execute? Pseudocode: start Declarations num count = 1 while count <= 7 output "I love CMIS130" count = count + 1 endwhile stop

7

how many times does the loop execute? For Counter = 1 To 7 System.Console.WriteLine("Hello") Next Counter

7

You have just starting working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. In the following pseudocode, what will be the value of sum after the code is run? Declarations num count = 0 num sum = 0 while count < 3 for X = 1 to 2 step 1 sum = sum + X endfor count = count + 1 endwhile

9

what is the relational operator used in VB to test for inequality?

<>

What VB statement does the same thing as this Java statement? final int MAX_NUMBER = 100;

Const MAX_NUMBER as Integer = 100

keyword necessary to declare a variable in VB

Dim

Assuming numBoxes is an integer variable and numBoxesString is String, what VB statement does the same thing as this Java statement: numBoxes = Integer.parseInt(numBoxesString)

NumBoxes = Convert.ToInt32(NumBoxesString)

when several decisions are based on the value of the same variable, structure many programming languages offer a shortcut

case structure

what are the types of VB programs?

console application, windows application, and web application

What is the loop control variable in the following statement? Dim Count As Integer = 0 Dim Sum As Integer = 0 Do While Count <= 7 Sum += Count Loop

count

any numeric variable you use to count the number of times an event has occurred

counter

a loop for which the number of iterations is predetermined; also called counted loop

definite loop

What is the loop control variable in the following pseudocode? input dep while not eof count[dep] = count[dep] + 1 input dep endwhile

dep

what method can be used to create a relational (boolean) expression with a string variable?

equals()

TRUE or FALSE: If the variable empDept = 4 and supervisorName is Jovee, the value of teamA is 1 after this code executes. [Assume teamA, teamB, and teamC were initialized to zero.] if(empDept < 4) if(supervisorName = "Jovee") teamA +=1; else if(supervisorName = "Islee") teamB +=1; else teamC +=1;

false

the indentation used in pseudocode impacts the flow of the statements, that is, the indentation affects whether or not a statement executes

false

what keyword is used in java to indicate a named constant variable?

final

Which of the following adheres to Java naming convention for a class? FinanceCalculator financeCalculator FINANCE_CALCULATOR financecalculator

financeCalculator

You have just starting working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working correctly. How should the for loop be changed? start Declarations num count = 0 num scores[6] = 0,0,0,0,0,0 num SIZE = 6 for count 0 to SIZE step input entry scores[count] = entry endfor stop

for count 0 to SIZE - 1 step 1

convenient tool when working with arrays because you frequently need to process every element of an array from beginning to end

for loop

this statement uses a loop control variable and provides you with three actions automatically in one compact statement: initialize, test, alter

for statement

In the following for loop, which statement or expression determines whether or not to loop again? int i; for(i = 0; i <= 5; i++) { sum += i; }

i <=5

The YumYum store sells ice cream. Single-scoops cost $2.00, double-scoops cost $2.80, and triple-scoops cost $3.50. There is a $10 bonus for ice cream store workers that have more than $100 of sales on their shift and sell more than four triple-scoop servings. What pseudocode will select the workers that will earn a bonus?

if Sales > 100 AND tripleScoop > 4

if a > 10 then if b > 10 then output "OK" endif endif

if a > 10 OR b > 10 then output "OK"

another name for a dual-alternative decision statement

if-else

How many times will the following loop execute? int counter = 0; while(counter < 5) { System.out.println("I love CMIS130!"); }

infinite loop

Your method body contains the following statements: String leftOrRight = " "; int rightTotal = 0; int leftTotal = 0; leftOrRight = JOptionPane.showInputDialog("Enter an L if you are left-handed, a R if you are right-handed (enter anything other than L or R to quit)"); while(leftOrRight.equals("L") || leftOrRight.equals("R")) { if(leftOrRight.equalsIgnoreCase("L")) leftTotal++; else rightTotal++; leftOrRight = JOptionPane.showInputDialog("Enter an L if you are left-handed, a R if you are right-handed (enter anything other than L or R to quit)"); } System.out.println("Left = " + leftTotal); System.out.println("Right = " + rightTotal); If these values are input to the program in this order: r r l r r x What is the output?

infinite loop

how many times does the following loop execute? Dim Count As Integer = 0 Do While Count <=3 System.Console.WriteLine("Hello") Loop

infinite loop

loop is a repeating flow of logic that never ends

infinite loop

what are the three pieces of logic incorporated for every loop?

initialize, test, and alter the loop control variable

what data type is most appropriate to store the number of goals Vladimir Tarasenko scores in the next game?

integer

Your method body contains the following statements: String leftOrRight = " "; int rightTotal = 0; int leftTotal = 0; leftOrRight = JOptionPane.showInputDialog("Enter an L if you are left-handed, a R if you are right-handed (enter anything other than L or R to quit)"); while(leftOrRight.equalsIgnoreCase("L") || leftOrRight.equalsIgnoreCase("R")) { if(leftOrRight.equalsIgnoreCase("L")) leftTotal++; else rightTotal++; leftOrRight = JOptionPane.showInputDialog("Enter an L if you are left-handed, a R if you are right-handed (enter anything other than L or R to quit)"); } System.out.println("Left = " + leftTotal); System.out.println("Right = " + rightTotal); What is the loop control variable?

leftOrRight.equalsIgnoreCase

this searches sequentially through a list from one end to the other

linear search

action or actions that occur within a loop

loop body

what method do all stand-alone java applications start with?

main()

process of updating programs after the programs are put into production

maintenance

what is placing a structure within another structure called?

nesting

is this a valid variable name when considering rules for naming identifiers in VB? 1stName

no

You have just starting working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working properly. The message should display five times. What needs to be changed? Declarations string message = "OK" while count < 5 output message count = count + 1 endwhile

num count = 0 should be added to declarations

which one doesn't produce the same result as the others? number+=; number+=1; number = number +1; number++;

number+=

You have just starting working at Quantum Company. As a new programmer, you have been asked to review and correct various pseudocode. The following pseudocode is not working correctly. What kind of error is this? start Declarations num count = 0 num scores[6] = 0,0,0,0,0,0 num SIZE = 6 for count 0 to SIZE step 1 input entry scores[count] = entry endfor stop

out of bounds

In the following code, which part of a statement converts a String to an int? numString = JOptionPane.showInputDialog("Enter a number."); num = Integer.parseInt(numString);

parseInt()

statement that reads the first input value in a program

priming input

The Billing Department manager, Anna, asked the programmer, Jerry, for a list of customers who owe the ABC Company more than $500. When Jerry plans the solution to this programming problem, he will use one of two tools to help him. These tools are: ____.

pseudocode and flowcharts

compares a variable to a series of values that mark the limiting ends of ranges

range check

what must your expression include in order to create an expression with a boolean result?

relational operator

the logic in a loop when the answer to the question results in the loop being entered and loop statements executing

returns to the question that started the loop

value such as "Y" or "N" that a user must supply to stop a loop

sentinel value

can contain any number of tasks, but there is no chance to branch off and skip any of the tasks

sequence

what structure is this? get firstNumber get secondNumber add firstNumber and secondNumber print result

sequence

all logic problems can be solved using what three structures?

sequence, selection, loop

what structure is this? if on the beach use sunscreen endif

single-alternative selection

what option must be set in order for the VB compiler to check data types in your assignment and arithmetic statements?

strict

variable that can hold letters of the alphabet and other special characters such as punctuation marks

string

number that indicates the position of a particular item within an array; also called an index

subscript

the ______ of a language are the rules that govern word usage and punctuation

syntax

Which of the following statements is NOT true of the structure of a Java application program? In the following statement, System is a class: System.out.println("Hello World"); The class header has to come before the method header. The method header has to come before an import statement. All method names are followed by parentheses ()

the method header has to come before an import statement

what are the two primary uses of arrays in business applications?

to produce totals and to provide a look-up table

all the variables in an array have the same data type and share a name

true

in an AND decision, it is more efficient to first ask the question that is less likely to be...

true

in an OR decision, it is more efficient to first ask the question that is more likely to be....

true

is this a properly formatted "if" statement in VB? T or F If UserInput = "T" Then System.Console.WriteLine("True that") Else System.Console.WriteLine("Tis false") End If

true

java considers all input coming from an input textbook to be String data

true

the java compiler recognizes the end of a java statement when it encounters either a semi-colon or a properly-paired closing curly brace

true

when you combine AND and OR operators, the AND expressions are evaluated first

true

name of Visual Basic compiler

vbc

if x > y is false, what is always true?

x <= y

does this variable name follow VB naming conventions? EmplSalary

yes

what VB statement does the same thing? firstName = JOptionPane.showInputDialog("Enter first name: ");

FirstName = InputBox$("Enter first name: ")

What part of the following Java statement is the name of a class? word1 = JOptionPane.showInputDialog("Please enter a noun:");

JOptionPane

Given the following code: for(loopIndex = 0; loopIndex < NUM_PLAYER_AVGS; loopIndex++) { averageString = JOptionPane.showInputDialog("Enter a batting average: "); battingAverage = Double.parseDouble(averageString); averages[loopIndex] = battingAverage; } You know all of the following statements to be true EXCEPT:

NUM_PLAYER_AVGS is the loop control variable

what VB data type is most appropriate to store the last name of the coach for the St.Louis Blues?

String

What VB statement does the same thing as this Java statement? System.out.println("Welcome to the Download Time Estimator");

System.Console.WriteLine("Welcome to the Download Time Estimator")

for EmpDept is 5, what is the value of SupervisorName after the following code executes? If EmpDept <= 3 Then SupervisorName = "Powell" Else If EmpDept <= 7 Then SupervisorName = "Yager" Else SupervisorName = "Hileman" End If

Yager

variable you use to gather or accumulate values

accumulator

java program that is executed and viewed in a browser

applet

java stand-alone program

application

what is the name of a java system variable that contains the length of the array you defined?

arrayName.length

this search starts looking in the middle of a sorted list, and then determines whether it should continue higher or lower

binary search

expression that represents only one of two states, true or false

boolean expression

the decision that controls every loop is always based on

boolean expression

what is output? String s1 = "CMIS"; String s2 = "Moore"; if(s1.equals(s2)) System.out.println("Both are interesting"); else System.out.println("Both are challenging");

both are challenging


Ensembles d'études connexes

Chapter 2: Trade-offs, Comparative advantage, and the market system

View Set

Career Readiness - Chapter 2 & 3

View Set

Solving Systems of Linear Equations: Linear Combinations

View Set

ATI NurseLogic Testing and Remediation

View Set

Chapter 3: Saving Money (Ramsey Classroom)

View Set

Важные слова турецкий

View Set