This is the main of my program all errors have been solved now I need help sorting my array list with a selection, bubble and insertion sort to print out in

alphabetic order using the name as key
numeric order using the income as key
order of nationality in alphabetic order

Each array must have its own class. Im clueless on how to do this and been sitting at the computer feeling stupid please help!!!!

// ***************************************************************************************
// Programmed by :  [[Alana R. Lewis]]
//Implement a set of classes that define various types of demographic information
//about a set of people, such as age, nationality, occupation, income and so on. 
//You will find appropriate classes defined below and illustrated in the UML diagrams.
// ****************************************************************************************
   import java.util.StringTokenizer;
   import java.util.ArrayList;  
   import java.util.Scanner;
   import java.util.Arrays;

    public class Demographics
       public static void main(String[] args)throws IOException 

         System.out.println("I did not receive any assistance from anyone other than Mr. Willis or an assigned tutor.\n");        

      // create a fileScan Scanner for a file, StudentNames.txt
         Scanner fileScan = new Scanner(new File("Demographics.txt"));  

         ArrayList people = new ArrayList();

      // check whether the fileScan has the next item (i.e., next line)
         while (fileScan.hasNext()) // // Read until file is exhausted

         // create a String Tokenizer for a line
            StringTokenizer st = new StringTokenizer( fileScan.nextLine());

            // read name from tokenizer
            String name = st.nextToken();

            // read income from tokenizer
            String ageString = st.nextToken();

            // convert gpa into double
            int age = Integer.parseInt( ageString );

            // read gender from tokenizer
            String gString = st.nextToken();

            // read gender from tokenizer
            Gender_Type gender = Gender_Type.valueOf( gString );

            // read nationality from tokenizer
            String nString = st.nextToken();

            // read nationality from tokenizer
            Nationality_Type nationality = Nationality_Type.valueOf( nString ); 

            // read occupation from tokenizer
            String oString = st.nextToken();

            // read occupation from tokenizer
            Occupation_Type occupation = Occupation_Type.valueOf( oString );

            // read income from tokenizer
            String incomeString = st.nextToken();

            // convert gpa into double
            double income = Double.parseDouble( incomeString );

            //new person and insert into arraylist  
            Person person = new Person();

            // do the sets
            // print the person



        //print arraylist


        //do the sorts
        //Print out List for Alphabetic Order(using the name as the key)
         System.out.println("\nAlpabetic Order List");

            //Print out list in numeric order (using income as key)

         System.out.println("\nNumeric Order List");

            //Print out list in order of nationality(Alphabetic Order)
         System.out.println("\nNationality Order List");


Edited 3 Years Ago by Dani: Formatting fixed

This article has been dead for over six months. Start a new discussion instead.