Create a program that will accept 20 numbers and arrange them in ascending order. The program should determine the distinct numbers and the number of occurrences for each number (or the frequency). Display the supplied values, the distinct numbers and the frequency of each distinct numbers.

Your program should use three arrays that will hold the entered numbers, distinct numbers, and the frequency, respectively.

Use the following numbers in your first run:
1 37 25 1 56 8 6 9 11 8 54 56 20 25 1 8 6 20 56 56

Enter 20 numbers:
1
37
25
1
56
8
6
9
11
8
54
56
20
25
1
8
6
20
56
56

20 37 25 1 56 8 6 9 11 23 54 56 20 25 1 8 56 20 56 56

``````Distinct Number	Frequency
1			3
37 			1
25 			2
56 			4
8 			3
6 			2
9 			1
11			1
54			1
20 			2``````

please give me a hand on this one, i've done the arranging thing, i just a hint on how can i do the rest, please help me, just clues please . . .

how can i do the rest

What have you tried so far? The program assignment gives you a helpful starting hint, with the part about the three arrays. This narrows down your possible solutions somewhat.

Try thinking about it with a piece of paper. I'm going to read off a list of numbers to you, …

## All 6 Replies

how can i do the rest

ok, my problem is the thing on how to get the distinct number within the 20 entered number and how many times they are entered

What have you tried so far? The program assignment gives you a helpful starting hint, with the part about the three arrays. This narrows down your possible solutions somewhat.

Try thinking about it with a piece of paper. I'm going to read off a list of numbers to you, you're going to write them down, then you're going to give me a list of unique numbers and how many times I read each of them, and you're going to do this by writing down three columns of numbers. How many places will you need in each column, first of all?

``````import java.util.*;
public class SfourA  {
public static void main ( String[] args )  {
Scanner nix = new Scanner ( System.in );
System.out.println ( "Enter 20 Numbers: " );
int inA = nix.nextInt();
int inB = nix.nextInt();
int inC = nix.nextInt();
int inD = nix.nextInt();
int inE = nix.nextInt();
int inF = nix.nextInt();
int inG = nix.nextInt();
int inH = nix.nextInt();
int inI = nix.nextInt();
int inJ = nix.nextInt();
int inK = nix.nextInt();
int inL = nix.nextInt();
int inM = nix.nextInt();
int inN = nix.nextInt();
int inO = nix.nextInt();
int inP = nix.nextInt();
int inQ = nix.nextInt();
int inR = nix.nextInt();
int inS = nix.nextInt();
int inT = nix.nextInt();
System.out.println ();
System.out.println ( "Entered Numbers are: " );
int [] inNum = new int ;
inNum  = inA;
inNum  = inB;
inNum  = inC;
inNum  = inD;
inNum  = inE;
inNum  = inF;
inNum  = inG;
inNum  = inH;
inNum  = inI;
inNum  = inJ;
inNum  = inK;
inNum  = inL;
inNum  = inM;
inNum  = inN;
inNum  = inO;
inNum  = inP;
inNum  = inQ;
inNum  = inR;
inNum  = inS;
inNum  = inT;
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  + "  " );
System.out.print ( inNum  );

}
}``````

. . . that's what i've done so far, arranging the entered number. . . please give me a hint on how am i gonna do with the distinct numbers and how frequent they were entered . . . what statement will i use, please give me a clue . . .

You need to study how to use loops and arrays. Throw this code out and start over.
When you read the numbers entered by the user, you put each number into a separate element of the array, not into individual variables. As each number is entered you change the index to the array to reference the next element in the array. This can easily be done by using a for loop.