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 6 of 6

Thread: Beginner pleasee help with java code

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Beginner pleasee help with java code

    Restriction the only structure my program is allowed to use for storage, is ArrayLists.
    The link to the problem I'm trying to solve is Powered by Google Docs

    So far what i got is this,(note that im not putting in the ";" yet)
    ____________________
    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
    Last edited by chuy525; October 24th, 2011 at 02:37 PM.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Beginner pleasee help with java code

    1. Enclose the code in
     tags
    2. Format the code properly, either use some editor.
    3. Read this
    4. And what is the problem?

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  4. #4
    Member
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    69
    My Mood
    Bored
    Thanks
    11
    Thanked 7 Times in 6 Posts

    Default Re: Beginner pleasee help with java code

    Quote Originally Posted by chuy525 View Post
    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)
    ____________________
    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.
    Last edited by william; October 24th, 2011 at 03:00 PM.

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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 + - * /

  6. #6
    Member
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    69
    My Mood
    Bored
    Thanks
    11
    Thanked 7 Times in 6 Posts

    Default Re: Beginner pleasee help with java code

    Quote Originally Posted by chuy525 View Post
    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.

Similar Threads

  1. Replies: 3
    Last Post: October 19th, 2011, 11:55 PM
  2. Anyone can help me with my code pleasee?
    By Kyo in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 29th, 2011, 08:07 AM
  3. Beginner trying to write Java code, has issue w/ printing result and 2 decimals
    By flpanthers1 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 5th, 2011, 11:11 AM
  4. help pleasee
    By YNWA in forum Object Oriented Programming
    Replies: 2
    Last Post: March 22nd, 2011, 09:39 PM
  5. Beginner - Help with my code.
    By eddross in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2010, 09:30 AM