Question: Write a program with a loop that asks the user to enter a series of even numbers. The user should enter the string done to
Write a program with a loop that asks the user to enter a series of even numbers. The user should enter the string done to signal the end of the series. After all the numbers have been entered, the program should display their sum. The program should ignore any number entered that is odd. A number is odd if the remainder is if divided by You will use the operator to computer the remainder. For example, would give you
Hint: Read the input as a string using scaner.nextLine Compare the string with "done". To convert a string to a int, use Integer.parseIntstring For example, int n Integer.parseInt converts the string to the integer
Sample run :
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:done
The sum is
Sample run :
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:
Enter a number type 'done' to end:done
The sum is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
