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 Data Structures (4th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Using MIS (10th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out With Visual Basic (7th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Database Concepts (8th Edition)
- 4. Write an if statement that increases pay by 3% if score is greater than 90, otherwise increases pay by 1%.arrow_forwardVariables 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_forward
- language is java levelarrow_forwardWrite 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 a multiway if-else statement that classifies the value of an int variable ninto one of the following categories and writes out an appropriate message:n < 0 or 0 ≤ n < 100 or n ≥ 100Hint: Remember that the Boolean expressions are checked in order.arrow_forward
- Write 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_forwardConvert the following conditional expression into an if/else statement. q = (x < y) ? (a + b) : (x * 2);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
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT