Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6220417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:57:12+00:00 2026-05-24T07:57:12+00:00

I’m trying to make a project that asks for the number of strings a

  • 0

I’m trying to make a project that asks for the number of strings a person wants, then prompts the person to enter the strings in any order. Then I am supposed to order them alphabetically and I CAN NOT use Java.util at all. I am supposed to use any type of sorting algorithm that can sort the inputted strings in alphabetical order. This is my code so far, could any one help me put a sorting algorithm in my code?

package sorting;
import java.io.*; 

 public class Sorting
 {
  private static BufferedReader stdin =  new BufferedReader( new InputStreamReader( System.in ) );

  public static void main(String[] arguments) throws IOException
 {
   System.out.println("How many strings would you like to enter?");
int stringCount = Integer.parseInt(stdin.readLine());
String[] stringInput = new String[stringCount];
String message = "";
for(int i = 0; i < stringCount; i++)
{
System.out.print("Could you enter the strings here: \n");
    stringInput[i] = stdin.readLine();
    message = message + stringInput[i] + ", ";
}
System.out.println("So you entered:\n" + message);    
}
private static void bubbleSort(String[] stringInput, int length) {
    int temp, counter, index;
    for(counter=0; counter<length-1; counter++) {
        for(index=0; index<length-1-counter; index++) {
            if(stringInput[index] > stringInput[index+1]) {
                 temp = stringInput[index];
                 stringInput[index] = stringInput[index+1];
                 stringInput[index+1] = temp;
            }
         }
      }
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:57:13+00:00Added an answer on May 24, 2026 at 7:57 am

    To point you in a direction think about the following…

    Basically the way it works is you have a list lets say in this case of ints

    int unsortedNums[] = new list[5];
    
    unsortedNums[0] = 1;
    unsortedNums[1] = 4; 
    unsortedNums[2] = 6; 
    unsortedNums[3] = 2; 
    unsortedNums[4] = 7; 
    

    1, 4, 6, 2, 7

    and you need to sort it from least to greatest. The way you would do this is like the following using pseudo code:

    //loop through the list
    for(int i = 0; i < unsortedNums.length; i++){
        if(unsortedNums[i] <= unsortedNums[i+1]){ //if current number is < next number
            //keep the number there because it is less than the next number
        }else{
            //you need to shift the current number to the right until because it is bigger
            //than the next number
        }
    }
    

    now this won’t completely sort it on the first try, [in this example that would make your list 1, 4, 2, 6, 7] you would either have to call this function again until the list is fully sorted, or you could look into recursion, or read up about any of the sorts like bubble sort, insertion sort, merge sort, and so on.

    It might be usful to mention to make sure you check your Array Bounds because if i+1 is bigger than your list you will get an exception so just keep this in mind.

    Good Luck with your Homework and remember, homework isn’t just another thing to add to your grade, but the real importance of homework is to learn and practice or else you will never understand and succeed in whatever class it is. If it is too easy, you probably didn’t learn anything. If it is hard, you probably will learn a lot even if you don’t always get it right.

    Happy Coding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.