OneCompiler

Write a java program that reads from the keyboard a set of integers terminated by -1. The program should computes and outputs the sum of odd integers read. However, the program should ignores integers greater than 20 in the input stream.

Write a java program that reads from the keyboard a set of integers terminated by -1. The program should
computes and outputs the sum of odd integers read. However, the program should ignores integers
greater than 20 in the input stream.
Hint: use a continue statement inside a while loop.
Test Cases: Use the following input to test your program:
Case 1: 5 8 24 9 25 3 10 -1 Answer: 17
Case 2: 5 8 9 3 10 -1 Answer: 17

No answers yet!

5 years ago by