Chapter 3: Problem 2
Write an if statement that multiplies payRate by 1.5 if hours is greater than 40.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
Chapter 3: Problem 2
Write an if statement that multiplies payRate by 1.5 if hours is greater than 40.
These are the key concepts you need to understand to accurately answer the question.
All the tools & learning materials you need for study success - in one app.
Get started for freeWrite an if-else statement that assigns 0 to the variable b and assigns 1 to the variable c if the variable a is less than 10. Otherwise, it should assign -99 to the variable \(b\) and assign 0 to the variable \(c\).
Rewrite the following if-else statements as statements that use the conditional operator. a) if (x > y) z = 1; else z = 20; b) if (temp > 45) population = base * 10; else population = base * 2; c) if (hours > 40) wages *= 1.5; else wages *= 1; d) if (result >= 0) System.out.println("The result is positive.)"; else System.out.println("The result is negative.");
Assume the variable name references a String object. Write an if statement that displays "Do I know you?" if the String object contains "Timothy".
Write nested if statements that perform the following test: If amount1 is greater than 10 and amount 2 is less than 100 , display the greater of the two.
Write an if-else statement that assigns 20 to the variable \(y\) if the variable \(x\) is greater than \(100 .\) Otherwise, it should assign 0 to the variable \(y\).
What do you think about this solution?
We value your feedback to improve our textbook solutions.