Question: Given the following Boolean variables: bool pass = true, open = false, run = true; Using a truth table, which of the following Boolean expressions

Given the following Boolean variables:

bool pass = true, open = false, run = true;

Using a truth table, which of the following Boolean expressions has the logical value false?

a. pass && !open || !pass && run

b. !pass || open && pass || run

c. pass && !open || pass || !run

d. !pass && !open || !pass && run

What value would the variable price hold after the following code is executed?

int price;

int tier = 2;

int year = 1995;

switch (tier)

{

case 1:

case 2:

if (year < 1990)

price = 300;

else

price = 400;

break;

case 3:

case 4:

if (year < 2000)

price = 500;

else

price = 600;

break;

Select one:

a. 300

b. 400

What would the value of payment be after the following code is executed?

char residency = 'N';

int payment, items = 300;

if (items > 400)

if (residency == 'N')

payment = 2500;

else

payment = 3000;

else if (items > 200)

if (residency == 'R')

payment = 1500;

else

payment = 1000;

Select one:

a. 1000

b. 1500

c. 2500

d. 3000

Which of the following is a valid implementation of a void method named Subtract ?

A.

void Subtract (x, y)

{double z;

z = x - y;

System.out.println("Result = ", z);

}

B.

Subtract (double x, double y)

{

double z = x - y;

System.out.println("Result = ", z);

}

C.

void Subtract (double x, y)

{z = x - y;

System.out.println("Result = ", z);

}

D.

void Subtract (x, y)

{

System.out.println("Result = ", x - y);

}

Which of the following correctly implements a method named Slowest ?

A.

void Slowest (double a, b, c)

{

if (a < b && a < c)

System.out.println(a);

else if (b < c)

System.out.println(b);

else

System.out.println(c);

}

B.

Slowest (double a, double b, double c)

{

if (a < b || a < c)

System.out.println(a);

else if (b < c)

System.out.println(b);

else

System.out.println(c);

}

C.

void Slowest (double a, double b, double c)

{

if (a < b && a < c)

System.out.println(a);

else if (b < c)

System.out.println(b);

else

System.out.println(c);

}

D.

void Slowest (double a, double b, double c)

{

if (a < b || a < c)

System.out.println(a);

else if (b < c)

System.out.println(b);

Else

System.out.println(c);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!