Results 1 to 3 of 3
  1. #1
    dj_ee3 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default Help with running the program :)

    Hello I just made a program for my CP AP class that consist of three different methods
    Java Code:
     public static ArrayList One(ArrayList <Integer> list, Integer value) 
        {
            int index = 0; 
            while(index< list.size() && value.compareTo(list.get(index)) > 0) 
                index++;
            list.add(index, value);
            return list;
        }
        public static int Two() 
        {
            ArrayList<String> list = new ArrayList<String>();
            int count = 0; 
            
            for (int i = 0; i<list.size(); i++) 
            {
                for (int b = 0; b<list.get(i).length(); b++)
                {    
                    if(list.get(i).substring(b, b+1).equals("a") || list.get(i).substring(b, b+1).equals("e") || list.get(i).substring(b, b+1).equals("i") 
                    || list.get(i).substring(b, b+1).equals("o") || list.get(i).substring(b, b+1).equals("u"))
                    {
                       count++;
                    }
                    else 
                    {
                        
                    }
                }
                    
            }
            return count; 
       }
       public static ArrayList Three() 
        {
            ArrayList<String> list = new ArrayList<String>();
    
           
            int count = 0; 
            
            for (int i = 0; i<list.size(); i++) 
            {
                for (int b = 0; b<list.get(i).length()-1; b++)
                {    
                    if(list.get(i).substring(b, b+2).equals("um") || list.get(i).substring(b, b+2).equals("uh"))
                    {
                       
                        list.remove(i);
                        i--;
                        if ( i < 0)
                        i = 0;
                    }
                    else 
                    {
                        
                    }
                }
                    
            }
            return list; 
       }
    The problem is that I am not really sure how to get it's output Can someone help me with that... I need to input the values of the arraylists and display the output.. Thank you in advice!

  2. #2
    nate0927 is offline Member
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    0

    Default

    I don't exactly understand what you want. Input or output?
    For output just use System.out.println(String);
    and thats lowercase ln
    for input you need to create a BufferedReader
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    and when it's method reader.readLine() is called, it will wait for the next line of input typed and return it as a string.
    I hope that is what you needed
    I think I understand now. Well you need to put them in a Main method so it runs on start, then you're gonna need some outputers.
    public static void main(String[] args) {
    ArrayList<String> a = One(list, value) //change those values to your input
    System.out.println(a.get(0);
    System.out.println(a.get(1); //repeat for each if it should be a fixed amount
    //if it's not fixed then do something like that
    for(int s = 0; s<a.size; s++){
    System.out.println(a.get(s);
    }
    }
    Last edited by nate0927; 02-27-2011 at 05:40 PM.

  3. #3
    dj_ee3 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

Similar Threads

  1. hi the program is compiling but not running why
    By javastuden in forum New To Java
    Replies: 6
    Last Post: 09-21-2010, 09:14 AM
  2. Running a program in a JPanel
    By ttelloow in forum Advanced Java
    Replies: 5
    Last Post: 07-26-2010, 06:18 PM
  3. my program is running bit slow!!
    By Arn00p in forum AWT / Swing
    Replies: 18
    Last Post: 05-05-2010, 04:14 PM
  4. Program running indefinitely
    By bayan in forum New To Java
    Replies: 2
    Last Post: 04-27-2010, 09:22 AM
  5. Running a Java Program
    By Valkyrie in forum New To Java
    Replies: 13
    Last Post: 11-05-2009, 03:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •