QuestionQuestion

Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). As they enter the data, assign it to a two-dimension array where the first dimension contains exactly what they type and the second dimension contains the first non-white space character of what they type, in lowercase. If they enter a blank line, it is acceptable to skip that line. When they type done, do these steps:
1. display: As Entered
2. for each entry in the array, display the index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon).
3. display: Bubble Sorted
4. using a bubble sort, for each entry in the array, display the original index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon) sorted by the second dimension.
5. display: Selection Sorted
6. using a selection sort, for each entry in the array, display the original index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon) sorted by the first dimension.

Example:
User types: apple Apple Zone apple done (i.e. per line)
Your display:
As entered
0:a:apple 1:a:Apple 2:z:Zone 3:a:apple
Bubble Sorted 0:a:apple 1:a:Apple 3:a:apple 2:z:Zone
Selection Sorted 1:a:Apple 0:a:apple 3:a:apple 2:z:Zone

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.*;
class project4{
Scanner input=new Scanner(System.in);
String[][] vect2 = new String[50][2]; //2-dimensional array
int length=0;
project4(){
String line="";
System.out.println("Enter items one per line. End with <<done>> written anyhow ");
while(length < vect2.length && !line.equalsIgnoreCase("done")){ //as long as "done", "Done", etc was not entered
line=input.nextLine();
if (!line.equalsIgnoreCase("done") && !line.isEmpty()){
vect2[length][0]=line; //1st dimension stores the content
vect2[length][1]=line.trim().toLowerCase().substring(0, 1) ; //2nd dimension stores the 1st non-empty letter
length++;
}...

By purchasing this solution you'll be able to access the following files:
Solution.docx and Solution.zip.

$48.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats