Chapter 3: Problem 21
Assume the variable name references a string object. Write an if statement that displays "Do I know you?" if the string object contains "Timothy".
Chapter 3: Problem 21
Assume the variable name references a string object. Write an if statement that displays "Do I know you?" if the string object contains "Timothy".
All the tools & learning materials you need for study success - in one app.
Get started for freeAssume that the double variable number holds the value \(7634869.1 .\) What format pattern would you use with a DecimalforMat object to display the number as \(7,634,869.10 ?\)
Assume that the double variable number holds the value \(0.179 .\) What format pattern would you use with a Decimalformat object to display the number as .18 ?
Rewrite the following if-else-if statement as a switch statement. If (selection = "A") System.out.println"You selected A." 1 If (selection = "B") System.out.println"You selected B." 1 If (selection = "C") System.out.println"You selected C." 1 If (selection = "D") System.out.println"You selected D." 1 else System.out.println"Not good with letters, eh?")
Rewrite the following if-else statements as statements that use the conditional operator. a) \(\quad\) if \((x>y)\) \(z=1\) else \(z=20 z\) b) \(if \text { (temp }>45)\) population - base \(\cdot 10\) else population = base \(\cdot 27\) c) if (hours \(>40\) ) wages \(*=1.5\) else wages \(*=1\) d) if (result \(>=0\) ) System.out.println ("The result in positive.") else System.out.println \((\) "The result is negative." )
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.
What do you think about this solution?
We value your feedback to improve our textbook solutions.