# Beginner pleasee help with java code

• October 23rd, 2011, 05:26 PM
chuy525
Beginner pleasee help with java code
Restriction the only structure my program is allowed to use for storage, is ArrayLists.

So far what i got is this,(note that im not putting in the ";" yet)
____________________
Code :

```import sdsu.io.*; import java.util.*; public class Problem {     public static void main(String args[]) {   ArrayList<String>[] list = new ArrayList[23]; for (int i=0; i<=22; i++) { list[i] = new ArrayList<String>(); }   for (int i = -999; i <= 999; i++) { int count = 0;   for(int k = 0; k <= 2; k++) { int a = s.charAt(k);   if(a == -){count++} if else(a == 0){count = count + 6} if else(a == 1){count = count + 2} if else(a == 2)[count = count + 5} if else(a == 3){count = count + 5} if else(a == 4){count = count + 4} if else(a == 5){count = count + 5} if else(a == 6){count = count + 6} if else(a == 7){count = count + 3} if else(a == 8){count = count + 7} if else(a == 9){count = count + 6}   }   int k1 = Console.readline("Input X'a milliamps:"); int k2 = Console.readline("Input Y's milliamps:"); int k3 = Console.readline("Input Z's milliamps");   k1 = k1 / 5 k2 = k2 / 5 k3 = k3 / 5;   int count = 0;     //* HERE: // Use the k1, k2, k3, list[], etc., to examine and compute // possible combinations for "X Op Y = Z", but use list[] to shortcut // your combinations so your program will not examine all 31 billion.   System.out.println("Possible solutions = " + count);   } //end main       public static int calcsegments(int i) { //* HERE: // Compute and return the number of segments in the number i, // where i is of course something in the range -999 to 999. }       } //end class```

i basically need help on the parts with the "*Here" on it. I think the rest is correct but i really dont know how to count all possible combinations depending on the number they enter for k1, k2, k3
• October 24th, 2011, 06:12 AM
Mr.777
Re: Beginner pleasee help with java code
1. Enclose the code in
Code java:

` tags`
2. Format the code properly, either use some editor.
4. And what is the problem?
• October 24th, 2011, 02:37 PM
chuy525
Re: Beginner pleasee help with java code
i basically need help on the parts with the "*Here" on it. I think the rest is correct but i really dont know how to count all possible combinations depending on the number they enter for k1, k2, k3
• October 24th, 2011, 02:57 PM
william
Re: Beginner pleasee help with java code
Quote:

Originally Posted by chuy525
Restriction the only structure my program is allowed to use for storage, is ArrayLists.

So far what i got is this,(note that im not putting in the ";" yet)
____________________
Code Java:

```import sdsu.io.*; import java.util.*; public class Problem {     public static void main(String args[]) {   ArrayList<String>[] list = new ArrayList[23]; //<--- what is this? for (int i=0; i<=22; i++) { list[i] = new ArrayList<String>();//<<--- /*I know what your trying to do here, I am not sure this is the approach.*/ }   //* HERE: // Use the k1, k2, k3, list[], etc., to examine and compute // possible combinations for "X Op Y = Z", but use list[] to shortcut // your combinations so your program will not examine all 31 billion.   System.out.println("Possible solutions = " + count); /*<--- think that your possible solution is the short cut? idea not solution. primitive array String[] str can access --> str[count] ??? */     //* HERE: // Compute and return the number of segments in the number i, // where i is of course something in the range -999 to 999.```

i basically need help on the parts with the "*Here" on it. I think the rest is correct but i really dont know how to count all possible combinations depending on the number they enter for k1, k2, k3

First review this ArrayList and array first

then comeback with your probabilities. You need to figure the probability math some links for it.
• October 24th, 2011, 05:50 PM
chuy525
Re: Beginner pleasee help with java code
I created to ArrayList[23] in order to store the number of calculator segments required to show for -999 to 999. For example if were checking 8, the number of segments required would be 7 and so we store it into list[8]. Can you come up with a code to help me do that or to examine and compute
the possible combinations for "k1 Op k2 = k3"..where OP is either + - * /
• October 24th, 2011, 06:38 PM
william
Re: Beginner pleasee help with java code
Quote:

Originally Posted by chuy525
I created to ArrayList[23] in order to store the number of calculator segments required to show for -999 to 999. /

you didn't read the document otherwise you would find that ArrayList[23] really does not relate to anything, please read then come back with some useful questions.