Question: IN JAVA Let the user input a sequence of positive integers by Scanner, and this number sequence shall be stored in an array. The length
IN JAVA
Let the user input a sequence of positive integers by Scanner, and this number sequence shall be stored in an array. The length of this array is set to be less than 1,000,000. The value of every number in this array is greater than 0 and less than or equal to 231-1. The number sequence shall end with -1. After the number -1, a number k will also be given by the user. Your job is to find the next number in the array after k. Please print your result to the console.
If the length of this array is 0, please print DNE.
If k does not exist in this array, please print DNE.
If k is located at the end of this array, please print DNE.
If the array contains duplicating ks, please find the next number after the first k.
Sample input/output:
Input
20 32 6 54 12 20 -1 6
Output
54

FindNext.java 1 import java.util.Scanner; public class FindNext { public static void main(String[] args) { ovou WN /* Your code goes here*/ 10 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
