Question: Using the Course Resource from Week Two called Understanding Pseudocode, Flowcharts, and the Test Plan, create a Word document that contains the pseudocode, flowchart, and
Using the Course Resource from Week Two called Understanding Pseudocode, Flowcharts, and the Test Plan, create a Word document that contains the pseudocode, flowchart, and test plan
Project
Write the following method that returns true if the list is already sorted in increasing order.
public static boolean isSortedint list
Write a test program that prompts the user to enter a list and displays whether the list is sorted or not.
Here is a sample run.
Sample Run
Enter the size of the list:
Enter the contents of the list:
The list has integers
The list is not sorted
Sample Run
Enter the size of the list:
Enter the contents of the list:
The list has integers
The list is already sorted
Class Name: Exercise
Code:
import java.util.Scanner;
public class Exercise
public static void mainString args
Scanner input new ScannerSystemin;
System.out.printEnter the size of the list: ;
int size input.nextInt;
int list new intsize;
System.out.printEnter the contents of the list: ;
for int i ; i size; i
listi input.nextInt;
System.out.printThe list has size integers ;
printArraylist;
if isSortedlist
System.out.printlnThe list is already sorted";
else
System.out.printlnThe list is not sorted";
input.close;
public static boolean isSortedint list
for int i ; i list.length ; i
if listi listi
return false;
return true;
public static void printArrayint arr
for int num : arr
System.out.printnum ;
System.out.println;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
