Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: sectionSort method in desceding order - Please help

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default sectionSort method in desceding order - Please help

    Hello, I am new to programming and new around here. I simply cannot figure these two things out. i haave been trying for a while.


    I need to know how to sort the rates r variable for the arrays in descending order using selectionsort. i think it would involve some kind of for loop.

    Also,
    I need to use reduceDebt to "request an amount from the user to be used to reduce the debt. reduce the debt starting with highest interest rate. the remainder is the amount left after reducing the debt. Again, I have no idea where to go with this any help is appreciated. below is my code

    public class sortparallelarrays
    {
     
        public static void  main (String [] args) {
            String [] card = {"Disney Rewards" , "Amazon Rewards", "Chase Sapphire", "Marriott Rewards"};
            String [] rates = {"14.24", "13.24", "15.24", "14.20"};
            String [] owed = {"4500.00", "1300.10", "3200.80", "775.00"};
            double amount;
     
     
     
     
        }
     
        public static void displayHeader()
        {
            System.out.printf("%8s %9s %10s %10s %16s  \n" , "Card", "Rate of Interest", "Amount owed", "In one year, you'll owe");
     
            System.out.println("===================================================================");
     
     
     
        }
     
        public static void displayValues(String [] c, double [] r, double [] owed)
        {
            System.out.printf("%8s %18s %25s \n", c, r, owed); 
     
        }
     
     
        public static void selectionSort(double [] r) 
        { 
           for (int i=0; i< r; i++) {
               for (int j=i+1; j< r; j++){
                   if (x[i] > x[j]){
                   int temp = x[i];
                   x[i] = x[j];
                   x[j] = temp;
                }
            }
     
        }
     
     
     
     
     
     
    }
    }
    Last edited by Norm; April 9th, 2013 at 10:27 AM. Reason: removed SPACES from code tag


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: sectionSort method in desceding order - Please help

    how to sort the rates r variable for the arrays in descending order using selectionsort.
    Get the algorithm for the sort from google
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Order of printing
    By DerrickMartin in forum Java Theory & Questions
    Replies: 2
    Last Post: February 20th, 2013, 05:54 AM
  2. [SOLVED] Alphabetical order
    By sbjibo in forum What's Wrong With My Code?
    Replies: 12
    Last Post: May 16th, 2012, 03:20 PM
  3. Replies: 3
    Last Post: June 1st, 2011, 12:47 AM
  4. Threads in some order...
    By aps135 in forum Threads
    Replies: 6
    Last Post: March 11th, 2011, 05:54 PM
  5. Stack Order?
    By TimW in forum AWT / Java Swing
    Replies: 2
    Last Post: September 19th, 2009, 07:33 AM