Concept explainers
Match the conditional expression with the if-else statement that performs the same operation.
a. q = x < y ? a + b : x * 2;
b. q = x < y ? x * 2 : a + b;
c. q = x < y ? 0 : 1;
____ if (x < y)
q = 0;
else
q = 1;
____ if (x < y)
q = a + b;
else
q = x * 2;
____ if (x < y)
q = x * 2;
else
q = a + b;
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Problem Solving with C++ (10th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Absolute Java (6th Edition)
Starting Out with C++: Early Objects (9th Edition)
Problem Solving with C++ (9th Edition)
- Variables father and child contains ages of a father and his child.Which if statement checks if father's age is more than 4 times his child's age? Lütfen birini seçin: a. if father // 4 > child: b. if father > 4 * child: c. if father > 4 * child d. if f > 4 * c: e. if father >= 4 * child:arrow_forwardWrite aprogram using nestedif statements that perform the following test: If the variable employed is equal to 'Y' and if worklength is equal or greater than 5, then display the message "Your credit card application is accepted". However, if worklength is less than 5, then display the message "Please provide a guarantor". Otherwise, if the variable employed is equal to 'N', then display the message "Your credit card application is rejected". C.arrow_forwardlanguage is java levelarrow_forward
- Write an if statement for the following: use if/else statement that assigns 1 to x if y is equal to 100. Otherwise it should assign 0 to x.arrow_forwardWrite an if statement that multiplies payRate by 1.5 if hours is greater than 40.arrow_forwardWrite an if statement that assigns 20 to the variable y, and assigns 40 to the variable z if the variable x is greater than 100. Write an if statement that assigns 0 to the variable b, and assigns 1 to the variable c if the variable a is less than 10. Write an if-else statement that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b. Write nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2.arrow_forward
- 5. Write an efficient if statement to assign x the value 1 if x ≤ 1.5, 2 if 1.5arrow_forwardIn C language The if...else statement executes two different codes depending .upon whether the test expression is true or false False True * In C language is invalid identifier su_b O intarrow_forwardUnlim Write an if-else statement that assigns True to fever if temperature is greater than 98.6; otherwise it assigns False to fever. 1 Enter your codearrow_forward
- Write a if-elif-else statement that distinguishes between a negative number or 0, a number between 0 and 50, and a number greater than or equal 50 by printing one of these three statements: {"It's negative or zero", "It's between 0 and 50", "It's greater than or equal to 50"}.arrow_forwardConvert the if-else statement to a single assignment statement using a conditional expression. Use parentheses around the condition. Enter "Not possible" if appropriate. if (x < 20) { y = X; else { y = 20;arrow_forwardWrite an if-else statement that works like this: If the sales variable is greaterthan or equal-to 50,000, the commissionRate variable should be assigned the value 0.2. Otherwise, the commissionRate variable should be assigned the value 0.1.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT