Chapter 3: Problem 1
Write an if statement that assigns 0 to \(x\) when \(y\) is equal to 20.
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 1
Write an if statement that assigns 0 to \(x\) when \(y\) is equal to 20.
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 code that tests the variable \(x\) to determine whether it is greater than \(0 .\) If \(x\) is greater than \(0,\) the code should test the variable \(y\) to determine whether it is less than \(20 .\) If \(y\) is less than \(20,\) the code should assign 1 to the variable \(z\). If \(y\) is not less than \(20,\) the code should assign 0 to the variable \(z\).
Explain why you cannot convert the following if-else-if statement into a switch statement. if (temp == 100) x = 0; else if (population > 1000) x = 1; else if (rate <.1) x = -1;
Write 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-else statement that assigns 0.10 to commission unless sales is greater than or equal to \(50000.0,\) in which case it assigns 0.2 to commission.
Write an if statement that assigns 0.2 to commission if sales is greater than or equal to 10000.
What do you think about this solution?
We value your feedback to improve our textbook solutions.