Write a program in java that reads a list of integers from input into an array and outputs "yes" if the list is sorted in ascending order between two provided positions. Otherwise, output "no". The first input specifies the number of items in the list. The next set of inputs is the list. The last two inputs are the start and end positions (inclusive). Assume the list contains less than 20 integers and position 1 is the first element. Ex: If the input is: 8 5 6 7 4 3 2 1 0 1 3 the output is: yes Ex: If the input is: 6 1 2 3 4 5 2 4 6 the output is: no   Code starts here: import java.util.Scanner;  public class LabProgram {    public static void main(String[] args) {       Scanner scnr = new Scanner(System.in);       int[] userValues = new int[20];   // List of integers from input       /* Type your code here. */    } }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 1PP: (Statistics) a. Write a C++ program that reads a list of double-precision grades from the keyboard...
icon
Related questions
Question

5.29 LAB: Is array sorted (JAVA)

 

Write a program in java that reads a list of integers from input into an array and outputs "yes" if the list is sorted in ascending order between two provided positions. Otherwise, output "no". The first input specifies the number of items in the list. The next set of inputs is the list. The last two inputs are the start and end positions (inclusive). Assume the list contains less than 20 integers and position 1 is the first element.

Ex: If the input is:

8 5 6 7 4 3 2 1 0 1 3

the output is:

yes

Ex: If the input is:

6 1 2 3 4 5 2 4 6

the output is:

no
 
Code starts here:

import java.util.Scanner; 

public class LabProgram {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int[] userValues = new int[20];   // List of integers from input

      /* Type your code here. */
   }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr