Hi evryone! :)
I'm a complete beginner in Java and today i'm found my self stack while trying
to solve a problem. Basically what i have to do is to write a program that sorts three integers.
The integers are entered from the input dialogs and stored in variables num1, num2, and num3,
respectively. The program sorts the numbers so that num1 <= num2 <= num3. I tryed everything i can,
but at the end still can't get the jobe done. PLEASE HELP!!! :'(
Muchas Gracias in advance!!! :)

But first of all you have to post what you have done so far?

First post where have you been stuck in your program?
We are ready to help in your code.

OK. All it takes to get a program is a little research and modification of the program to suit your needs. I found a program on the web and modified it for user's input. Here's the program, hope it helps.

PS: I am also new to Java, one year, but I research, learn, try, and ask for help. That's what helped me increase my ability to code in Java.

import static java.lang.System.*;
import java.util.Scanner;

class OrderPlacement3 {

 public static void main(String[] args) {
        int num1, num2, num3;

        //Gets the users input
        Scanner input = new Scanner(System.in);
          out.print(" Enter first number    ===>> ");                                       
          num1 = input.nextInt();
          out.print(" Enter second number   ===>> ");                                       
          num2 = input.nextInt();
          out.print(" Enter third number    ===>> ");                                       
          num3 = input.nextInt();
        out.println();

        //Without using Arrays.sort function
        int i;
        int nos[] = {num1, num2, num3};             
        sort(nos, nos.length);
        System.out.print("Values after sorting: \n");       
        for(i = 0; i <nos.length; i++){
            System.out.println(nos[i]+"  ");
        }
    }

    private static void sort(int nos[], int n) {
     for (int i = 1; i < n; i++){
          int j = i;
          int B = nos[i];
          while ((j > 0) && (nos[j-1] > B)){
            nos[j] = nos[j-1];
            j--;
          }
          nos[j] = B;
        }
    }
}

if you are new to Java, don't just copy paste some code you've
"found [a program] on the web"

write your own. a sorting algorithm is pretty basic and very easy.
go step by step.
write a small piece of pseudo code and implement that.

Start4Me: never just provide custom code, give them a chance to work on it themselves.

I research, learn, try, and ask for help. That's what helped me increase my ability to code in Java.

Yes, absolutely right.
But how does this fit with your posting a complete undocumented uncommented solution that the OP can just copy/paste without any understanding? I hope in your future posts you will prefer to help and guide the OP so they can laern how to solve the problem for themself

Thank you stultuske and JamesCherrill for advice. I will take that as a lesson, however, when I got stuck in the past and asked for help, those who tried to help me by posting "a small piece of pseudo code", never actually helped me, rather got me more confused. What approach could be more helpful is providing a "pseudo code" with a commentary on where to implement the code in the program, rather than giving a code that won't resolve the program completely.

you can't hold starters by the hand.
have you told those that you didn't understand the pseudocode, and wanted some additional explanation? it's impossible for those who try to help you to know what level of experience/knowledge you are.
sometimes it is better to not immediately understand the help given, and do some additional investigation yourself.
it'll help you understand it better than being handed the(/a) sollution.

Pseudo-code plus commentary is fine. Just remember that when a beginner asks for assistance we prefer to help them solve the problem themselves, and learn from the process. That will require them to do some work andf may take some time, but that's how people learn best. Giving someone perfect homework to hand in isn't really what this is about.

Hmm there is a good example of 3 different algorithms for sorting.
You can learn about that algorithms on this link.

  1. This is a bit late
  2. He's specifically sorting three nunbers. A general discussion of sort algorithms and their speed isn't relevant.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.