Question: Write a program that reads a list of integers from input into an array and outputs yes if the list is sorted in ascending order

Write a program 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,1-based). Assume the list contains less than 20 integers and position 1 is the first element (positions
are 1-based, so, for example, an 8-element array would have positions 1-8).
Ex: If the input is:
Enter size of the array: 8
Enter 8 integers, separated by a space: 56743210
Enter start and end positions, separated by a space: 13
Sorted: yes
Ex: If the input is:
Enter size of the array: 6
Enter 6 integers, separated by a space: 123452
Enter start and end positions, separated by a space: 46
the output is:
Sorted: no
Skeleton:
import java.util.Scanner;
public class IsListSorted{
public static void main(String[] args){
Scanner scnr = new Scanner(
System.in);
int[] userValues = new int[20]; // List of integers from input
//
Write a program that reads a list of integers

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 Programming Questions!