Question: Create a Java console program that satisfies the following: The program prompts a user to enter a number. The program uses the input value to
Create a Java console program that satisfies the following:
- The program prompts a user to enter a number. The program uses the input value to create an array with the number of elements based on the first input value.
- The program asks the user to enter a series of numbers, and the numbers are to be entered and stored in the array.
- The program asks the user to select the way of how the numbers are sorted, i.e., ascending or descending. If the user enters a, the numbers are sorted in ascending order (and displayed). If the user enters d, the numbers are sorted in descending order (and displayed).
- The program asks the user whether he/she wants to continue. If the user enters c or C, the program continues and repeats the process again. If the user enters any other key, the program stops.
|
C:\CIS314>java Exam01TomJones Enter a positive integer: 3 Enter item 1: 4 Enter item 2: 2 Enter item 3: 7
You have entered 4 2 7 How to display the numbers? Enter a for ascending, or d for descending: a The numbers in ascending order: 2 4 7
To continue, enter c; to quit, enter any other key: c Enter a positive integer: 4
Enter item 1: 7 Enter item 2: 6 Enter item 3: 3 Enter item 4: 9
You have entered 7 6 3 9 How to display the numbers? Enter a for ascending, or d for descending: d The numbers in descending order: 9 7 6 3
To continue, enter c; to quit, enter any other key: q
C:\CIS314>
|
Your code should follow the following requirement:
- Do not use Javas default methods to sort numbers. You must create your own methods to sort numbers in a separate class.
- Use the default package. Do not create your own packages.
- The algorithms for sorting numbers should be managed in methods of a separate class (e.g., NumberSort). Do not place the methods in the class that has a main() method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
