CIS 223 CH 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The following statements are equivalent, given that x = 4 and y = 3: z = Math.pow(y, x); and z = x * x * x;

False

The following test condition for an if... structure will be true if x = 2: if(x < 5 && x > 10

False

The if clause and the else clause of an if...else structure must always contain different test conditions.

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.

False

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

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

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

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

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!");

Morris is a cat.

What would the following code snippet display? var x = 5; if(x == 4) document.write("Math is fun!"); else document.write("Wrong! <br />"); document.write("Math is not fun!");

Wrong! Math is not fun!

A valid test condition could be (x = 10), assuming x is an integer variable.

False

Which statement is equivalent to the following: (x >= 0) && (x <= 100)

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

Which statement is equivalent to the following? (X > 6)

!(x <= 6)

What integer values of x would make the following statement true? (x >= 2) && (x < 6)

2, 3, 4, 5

A switch structure is a multiple alternative selection structure.

True

If an if clause or an else clause contain only one statement, curly brackets are not necessary.

True

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

True

The following test condition will evaluate to true if x = 5: if(x < 3 || x == 5)

True

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

True

What is the result of the following statement, given that count = 6? if (count == 6)

True

What integer values of y would make the following statement true? (y >= 4) || (y < 8)

all integers

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";

grade < 85

Which code snippet is equivalent to: var message = (y == 10) ? "correct" : "incorrect";

if (y == 10) message = "correct"; else message = "incorrect";

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

num = Math.floor(num);

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

num = Math.sqrt(64);

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?

rate

What will display after the following code is run if x = 3? switch(x) { case 1: document.write("one!"); case 2: document.write("two!"); case 3: document.write("three!"); default: document.write("go!"); }

three!go!


Set pelajaran terkait

nur 111 - Davis - Left and Right Heart Failure

View Set

Ibrahim Breaks the Idols/ قصّة سيّدنا إبراهيم: إِبْرَاهِيم يَكْسِرُ الأصْنَام Story 4

View Set

Six Sigma Green Belt-Value of Six Sigma

View Set

Psy 344 Armor Chs #1-5 Cultural Psychology (3rd Edition) Heine Reading Highlights Spring 2020 SDSU

View Set