Chapter 3: Problem 7
Write an if statement that displays "Goodbye" if the variable myCharacter contains the character ' D'.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 3: Problem 7
Write an if statement that displays "Goodbye" if the variable myCharacter contains the character ' D'.
All the tools & learning materials you need for study success - in one app.
Get started for free
Assume the variables \(a=2, b=4,\) and \(c=6 .\) Circle the \(T\) or \(F\) for each of the following conditions to indicate if it is true or false.
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.");
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.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-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.