Question: PLEASE Help! Need answer in 30 minutes! Java! 1. Re-write the following code so that there isn't a trailing comma on that output. (The current
PLEASE Help! Need answer in 30 minutes! Java!
1. Re-write the following code so that there isn't a trailing comma on that output. (The current code will output "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, " but there shouldn't be a comma after the 10)
int count = 1;
while (count <= 10) { System.out.print(count + ", "); count++; }
2. Write a method called hasOddDigit that returns a boolean value and receives an integer. The method should return true if the integer has an odd digit or false otherwise. For example, the following would all return true since at least one digit is odd: hasOddDigit(1), hasOddDigit(274) and hasOddDigit(789). The following, however, would all return false:hasOddDigit(46), hasOddDigit(2) and hasOddDigit(48062). Hint: You will need to use integer division and modulus.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
