Chapter 3: Problem 2
Write an if statement that multiplies payRate by 1.5 if hours is greater than 40 .
Chapter 3: Problem 2
Write an if statement that multiplies payRate by 1.5 if hours is greater than 40 .
All the tools & learning materials you need for study success - in one app.
Get started for freeWrite an 11 statement that displays the message "The number is not valid" if the variable speed is outside the range 0 through 200 .
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." )
Assume the following variable declaration exists in a program: Int number \(=123456\) Write a statement that uses system.out.printf to display the value of the number variable in a field that is 10 spaces wide, with comma separators.
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.
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?")
What do you think about this solution?
We value your feedback to improve our textbook solutions.