-
Descending order for arrays by name
Hi, thank you to all the people who previously helped me before....
Is there a way to sort an array in decending order by name?
I was trying to figure out what to do but this is what i have so far
double [] Salary = new double [10];
String [] Names = new String [10];
int i, j;
for ( i = 0; i < 10; i++)
{
System.out.print(" Name is: " + Names);
Names = ReadInput.StringRead(); //asks user for Salry
System.out.println(" Salary is: " + Salary );
Salary = ReadInput.readDouble(); //asks user for Names
}
for (j=0; j < 10; j++)
{
System.out.println(Names[j] + ": " + Salary[j]);
}
-
you can use the sorting in the Collections class. as for your homework (on your other post), we had one like this the other semester. maybe my homework can get you started if i'm not too late. post your e-mail address and i'll send some stuff to you.
-
-
-
is this right
i was trying to compare it but i am not sure if this is right or not
public Compare() {
double [] Salary = new double [10];
String [] Names = new String [10];
String nameTemp = new String();
double salaryTemp = 0.0;
int i, j;
for ( i = 0; i < 10; i++)
{
System.out.print(" Name is: " + Names[i]);
Names[i] = ReadInput.StringRead(); //asks user for Salry
System.out.println(" Salary is: " + Salary[i] );
Salary[i] = ReadInput.readDouble(); //asks user for Names
}
for (j=0; j < 10; j++)
{
System.out.println(Names[j] + ": " + Salary[j]);
//nameTemp = Names[i];
//Names[i] = Names[j];
//Names[j] = nameTemp;
//salaryTemp = Salary[i];
//Salary[i] = Salary[j];
//Salary[j] = salaryTemp;
//System.out.println(nameTemp + ": " salaryTemp );
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|