Results 1 to 3 of 3
Thread: Help with running the program :)
- 02-27-2011, 04:38 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 6
- Rep Power
- 0
Help with running the program :)
Hello I just made a program for my CP AP class that consist of three different methods
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!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; }
- 02-27-2011, 05:29 PM #2
Member
- Join Date
- Jan 2011
- Posts
- 1
- Rep Power
- 0
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.
- 02-27-2011, 11:19 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
hi the program is compiling but not running why
By javastuden in forum New To JavaReplies: 6Last Post: 09-21-2010, 09:14 AM -
Running a program in a JPanel
By ttelloow in forum Advanced JavaReplies: 5Last Post: 07-26-2010, 06:18 PM -
my program is running bit slow!!
By Arn00p in forum AWT / SwingReplies: 18Last Post: 05-05-2010, 04:14 PM -
Program running indefinitely
By bayan in forum New To JavaReplies: 2Last Post: 04-27-2010, 09:22 AM -
Running a Java Program
By Valkyrie in forum New To JavaReplies: 13Last Post: 11-05-2009, 03:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks