Question: ? Question (4) Write a Java program (One class with a main method) to do the following: 1- Ask the user to enter n that
Question (4) Write a Java program (One class with a main method) to do the following: 1- Ask the user to enter n that represents the length of the array. 2- Declare an array of size n of type integer and prompt the user to enter the values of the array. 3- Check if the entered values in the array are sorted ascendingly (smallest tollargest) or not and display an appropriate message. Sample Input/output: Enter n:4 Enter Values: 10203040 The values in the array are sorted Enter n: 4 Enter Values: 105302 The values in the array are not sorted import java.util.Scanner; public class arrayDemo \{ public static void main(String[] ] args) \{
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
