Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MULTIPLE CHOICE 1. Which of the following should be used to make the code snippet work for students who get any score between 0 100?

MULTIPLE CHOICE

1. Which of the following should be used to make the code snippet work for students who get any score between 0 100?

var grade = 0;

var score = parseInt("What's the score?");

if (score < 70)

grade = "F";

else if ( ??? )

grade = "C";

else if (grade >= 85)

grade = "A";

a.

grade > 70 && grade < 85

b.

grade >= 70 && <= 85

c.

grade >= 70

d.

grade < 85

2. Which code snippet is equivalent to:

var message = (y == 10) ? "correct" : "incorrect";

a.

if (y == 10)

message = "incorrect";

else message = "correct";

b.

if (y == 10)

message = "correct";

else if (y < 10)

message = "incorrect";

|| if((y >10)

message = "incorrect";

c.

if (y == 10)

message = "correct";

else message = "incorrect";

d.

none are equivalent

3. What integer values of x would make the following statement true?

(x >= 2) && (x < 6)

a.

2, 3, 4, 5, 6

b.

3, 4,5

c.

3, 4, 5, 6

d.

2, 3, 4, 5

4. What integer values of y would make the following statement true?

(y >= 4) || (y < 8)

a.

4, 5, 6, 7

b.

all integers

c.

4, 5, 6, 7, 8

d.

5, 6, 7

5. What would the following code snippet display?

var x = 5;

if(x == 4)

document.write("Math is fun!");

else

document.write("Wrong!
");

document.write("Math is not fun!");

a.

Math is fun!

b.

Math is fun!

Math is not fun!

c.

Wrong!

d.

Wrong!

Math is not fun!

6. You are asked to write a program that will display a letter that corresponds with a numeric rating system. The program should use a switch statement. The numeric rating is stored in a variable named rate and rate may equal 1, 2, 3, or 4. The corresponding letter is stored in a variable named grade and grade may be A, B, C, or D. Which is the test expression for this switch statement?

a.

rate

b.

grade

c.

1, 2, 3, or 4

d.

A, B, C, or D

7. What will display after the following code is run if z = 3?

switch(x)

{

case 1:

document.write("one!");

case 2:

document.write("two!");

case 3:

document.write("three!");

default:

document.write("go!");

a.

nothing will display

b.

three!

c.

one!two!three!

d.

one!two!three!go!

8. What will display after the following code is run if name = "Morris"?

if(name > "Joe")

document.write("Morris is a cat.");

else

document.write("Joe rules!");

a.

Joe rules!

b.

Morris is a cat.

c.

Morris is a cat.Joe rules!

d.

nothing cannot compare these values

9. Which statement is equivalent to the following:

(x >= 0) && (x <= 100)

a.

!(x < 0) && (x > 100)

b.

(x < 0) && (x > 100)

c.

(x >= 0) || (x <= 100)

d.

!((x < 0) || (x > 100))

10. What is the result of the following statement, given that count = 6?

if (count == 6)

a.

true

b.

false

c.

6

d.

not enough information given

11. Which statement is equivalent to the following?

(X > 6)

a.

!(x <= 6)

b.

( x <= 6)

c.

(x < 6 || x == 6

d.

(x < 6 && !(x == 6)

12. Which of the following will set the variable num to the value 8?

a.

num = pow(2, 3);

b.

num = sqrt(64);

c.

num = Math.pow(64, 2);

d.

num = Math.sqrt(64);

13. Which of the following will set the variable num to the value of 10 if num = 10.3625?

a.

num = floor(10.3625);

b.

num = Math.abs(10.3625);

c.

num = Math.floor(num);

d.

Math.floor(num);

14. Which of the following will generate a random number between 0 and 5?

a.

Math.random() * 5;

b.

Math.floor(Math.random() * 6));

c.

Math.random() * 5 + 1;

d.

Math.floor(Math.random() * 4 + 1);

15. Which of the following will generate a random number between 1 and 6?

a.

Math.random() * 6;

b.

Math.floor(Math.random() * 5 + 1));

c.

Math.random() * 6 + 1;

d.

Math.floor(Math.random() * 6 + 1);

TRUE/FALSE

1. True/False: In an if... structure, the only possible outcomes are either: a block of statements are executed or nothing is executed.

2. True/False: A valid test condition could be (x = 10), assuming x is an integer variable.

3. True/False: The following test condition for an if... structure will be true if x = 2:

if(x < 5 && x > 10)

4. True/False: The result of any test condition is always either true or false.

5. True/False: The following test condition will evaluate to true if x = 5:

if(x < 3 || x == 5)

6. True/False: The following statements are equivalent, given that x = 4 and y = 3:

z = Math.pow(y, x);

and z = x * x * x;

7. True/False: While it is possible to nest an if...else structure within an if... structure, it is not possible to nest an if... structure inside if...else structure.

8. True/False: The if clause and the else clause of an if...else structure must always contain different test conditions.

9. True/False: If an if clause or an else clause contain only one statement, curly brackets are not necessary.

10. True/False: A switch structure is a multiple alternative selection structure.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions