Computer Applications for Business - Exam 2 - Spring 2023

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/39

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

40 Terms

1
New cards

program

algorithms that have been specialized to a specific set of conditions and assumptions.

2
New cards

Can the words program and algorithm be used interchangeably?

They shouldn't be!

3
New cards

heuristic process

helpful procedure for finding a result, often an approximation for a solution.

4
New cards

What are the five steps for creating an algorithm?

1) Input Specified

2) Output Specified

3) Definiteness

4) Effectiveness

5) Finiteness

5
New cards

True or False? Algorithms CAN be specified at different levels of detail

True

6
New cards

True or False? Algorithms NEVER build on functionality previously defined and known to the user

False; it should be ALWAYS

7
New cards

True or False? Two different algorithms can be used to get the SAME solution in different amounts of time

True; the solutions can be equal even if one algorithm is much more complex than the other

8
New cards

Flowchart

A visual representation of the sequence of events to be performed by the algorithm

9
New cards

Consider the following JavaScript code segment:

var a = Number("23" + "321") / 1000;var b = a.toFixed(2);

What is the final value of b?

23.32

10
New cards

A Boolean value can only be either true or false

True

11
New cards

In JavaScript, the statement var x, y = 4; will assign the value 4 to:

A) y only

B) neither x nor y

C) both x and y

D) x only

A

12
New cards

Select all that apply. Which of the following is(are) required of an algorithm?

A) It must be executable without further external support.

B) It must specify every step and the order the steps must be performed.

C) It must, eventually, end.

D) Input and output must be specified.

All of the above

13
New cards

When creating a flowchart, the symbol for a decision is the parallelogram and the symbol for an assignment is a rectangle.

False

14
New cards

Select all that apply. Which of the following are valid variable declarations?

A) myName = "Snoopy";

B) var 1stName;

C) var x;

D) var myName = 23;

B, C, and D

15
New cards

In JavaScript, the statement 17 % 5 results in

A) 3

B) 0.175

C) 2

D) 3.4

C

16
New cards

var i = 28; if ( i / 2 % 2 > 0 ) {

document.write("The number is an odd integer");

}

else {

document.write("The number is an even integer");

}

What is displayed when the code segment above is executed?

A) The number is an even integer.

B) The number is an odd integer.

C) Nothing is printed. The result of the computation is equal to 0.

D) Nothing is printed. There is a runtime error.

A

17
New cards

What is the final value of z after following JavaScript code segment is executed?

var x = 12, y = 9;

var z = x / 2 + y / 3 + "88" ;

988

18
New cards

What is the value of the variable shipping if cost = 50 and country = "Canada"?

if (cost < 50 && country == "Canada")

shipping = 6.00;

if (cost < 100 && cost > 49 && country == "Canada")

shipping = 9.00;

else

shipping = 12.00;

A) 12.00

B) 6.00

C) 9.00

D) cannot tell since the else clause does not specify the conditions

C

19
New cards

True or False?

var green = -5;

The expression ! (green) will change the sign of the value on the variable green.

False

20
New cards

Assume the following JavaScript variable assignments have been made:

var a = 2, b = 4;

The Boolean expression a == 4 || b > 2 evaluates to _____?

A) True

B) False

True

21
New cards

Consider the following code segment.

var a = 3;

var b = 8;

var c = 4;

a = a + 1;

b = b - 1;

c = c + a;

What are the final values of a, b, and c?

a = 4

b = 7

c = 8

22
New cards

The condition on the if statement below to set the taxRate to 0.15 for the residents of the states of New Jersey and New York would be (assume the variable state has been declared and has a value):

if (condition)

taxRate = 0.15;

A) state == "NJ" && state == "NY"

B) state == "NJ" || state == "NY"

C) state == "NJ" && "NY"

D) state = "NJ" || state = "NY"

B

23
New cards

What is output?

var x = 10;

if (x > 5) {

x = 1;

}

else {

x = 0 ;

}

document.write(x);

A) nothing is output

B) 1

C) 0

D) 10

B

24
New cards

True or False? If a function definition contains two parameters, two arguments must be included in the function call.

True

25
New cards

True or False? Variables in the parameter list of a JavaScript function are declared automatically.

True

26
New cards

If you wanted the following function to return only the two values of 0 and 1, how would you re-write line 2?

function tossIt( ) {

return Math.random( );

}

A) return Math.round(random());

B) return Math.round();

C) This cannot be done.

D) return Math.round(Math.random());

D

27
New cards

True or False? A function definition is the same as a function call.

False. Defining a function says what the function is, while calling a function determines when/where you are using it.

28
New cards

True or False? Local variables cannot be accessed outside the functions in which they are declared.

True

29
New cards

How many iterations will occur in the following loop?

for(var again = 0; again < 5; again++) {

...

}

A) four

B) six

C) five

D) cannot tell

C

30
New cards

Which of the following is the correct code for the step size of the loop shown to ensure that the loop will repeat exactly five times?

for ( c = 3; c < 13; ________)

A) c = c + 2

B) c++

C) c = c + 3

D) c = c + 4

A

31
New cards

If you have a nested loop structure where the outside loop runs five times and the inside loops runs seven times, the statements of the inside loop will be executed ________ times.

A) twelve

B) seven

C) thirty-five

D) five

C

32
New cards

Which of the following statements is TRUE about the following JavaScript declaration?

var rows = new Array(5);

A) The last item in the array will be rows[5].

B) The first item in the array will be rows[0].

C) All of these are true.

D) The array will have six items.

B

33
New cards

Consider the JavaScript code segment below:

var choco = new Array("Hershey", "M&M", "Godiva", "Cadbury");

var yumCandy = choco[choco.length - 1];

What us the value of yumCandy>:

A) M&M

B) Cadbury

C) Hershey

D) Godiva

B

34
New cards

True or False? It is possible to set up a loop that never iterates.

True

35
New cards

Which of the following is an infinite loop?

A) for (k = 1; k <= 4; k = k - 1)

B) for (k = 1; k < 3; k = k + 1)

C) for (k = 0; k <= 10; k = k + 1)

D) for (k = 1; k <= 4; k = k + 1)

A

36
New cards

Consider the following JavaScript code segment.

var sum = 0;

var arr = new Array(7,1,6,9,4);

for(var i = 2; i < arr.length; i++){

sum += arr[i];

}

document.write(sum);

What is displayed when this code is executed?

A) 19

B) 20

C) 27

D) Nothing would be printed; An error would occur.

A

37
New cards

Which of the following is the correct way to declare an array named myArray with ten elements?

A) var myArray = new(10);

B) new myArray = Array(10);

C) var myArray = new Array(10);

D) myArray = new var(10);

C

38
New cards

An algorithm is a(n)

A) list of general nonspecific steps to produce an output

B) logarithm

C) systematic method for producing a specified result

D) math problem

C

39
New cards

Algorithms must always

A) produce output

B) produce output or state that there is no solution

C) produce input or state that there is no solution

D) state that there is no solution

B

40
New cards

Given this array: var cars = new Array(9); which of the following is a valid way of accessing a valuewithin the array.

A) cars[9]

B) cars[7.5]

C) cars[0]

D) cars[10]

C