I am currently working on a program that will read ints from a file (no more than 100 on file)sorts them in decending order and counts how many times each number occurs. I'm still a little new to this so be gentle :).
My input file looks as follows:
75 85 90 100
60 90 100 85
75 35 60 90
100 90 90 90
60 50 70 85
75 90 90 70
What the program needs to output is:
100:3
90:8
85:3
75:3
70:2
60:3
50:1
35:1
Here is my code so far it isnt much but I have been testing to see if my array works. Just showing my main because my other methods arent working such as my sort. Any help would be greatly appreciated, thank you.
public static void main(String[] args)
{
InputFile ifile;
ifile =new InputFile("C:\\ Documents and Settings\\Owner \\Frequency\\sr c\\test.txt");
Keyboard kbd;
kbd = new Keyboard();
int [] a;
a=new int[100];
int scores=0;
int x=-1;
int y=0;
int z=0;
while(!ifile.eo f())
{
scores = ifile.readInt() ;
a[x+1]=scores;
x++;
y++;
}
while (z!=y)
{
System.out.prin tln(a[z]);
z++;
}
}
My input file looks as follows:
75 85 90 100
60 90 100 85
75 35 60 90
100 90 90 90
60 50 70 85
75 90 90 70
What the program needs to output is:
100:3
90:8
85:3
75:3
70:2
60:3
50:1
35:1
Here is my code so far it isnt much but I have been testing to see if my array works. Just showing my main because my other methods arent working such as my sort. Any help would be greatly appreciated, thank you.
public static void main(String[] args)
{
InputFile ifile;
ifile =new InputFile("C:\\ Documents and Settings\\Owner \\Frequency\\sr c\\test.txt");
Keyboard kbd;
kbd = new Keyboard();
int [] a;
a=new int[100];
int scores=0;
int x=-1;
int y=0;
int z=0;
while(!ifile.eo f())
{
scores = ifile.readInt() ;
a[x+1]=scores;
x++;
y++;
}
while (z!=y)
{
System.out.prin tln(a[z]);
z++;
}
}
Comment