Question: use Linux code please 5) (15 marks) Write a Java program named a1q5.java which reads positive integers from the input and prints every second integer

 use Linux code please 5) (15 marks) Write a Java programnamed a1q5.java which reads positive integers from the input and prints every

use Linux code please

5) (15 marks) Write a Java program named a1q5.java which reads positive integers from the input and prints every second integer to the output. The program stops when it reads the first negative integer or zero, without printing it. However, the program must also print a -1 at the very end. Input: The input consists of a sequence of integers, one integer per line, where all integers are positive except the last one. For example, the input could be: 7 3 2 0 Output: The output will also consists of a sequence of integers, which consists of each second positive integer from the input, with the final line containing -1. For example, the output of the above input must be

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!