+ Reply to Thread
Results 1 to 5 of 5

Thread: Java

  1. #1
    swirly's Avatar
    swirly is offline x10 Elder swirly is an unknown quantity at this point
    Join Date
    Jul 2005
    Location
    NC
    Posts
    965

    Java

    I'm guessing this is the right place. I ned help with an assignment. I have to write a program in JAVA. I just need to know how to concantenate 3 integers.
    Code:
    class SumDigit
    {   public static void main(String args[])
        {
            int proof=0;
            for(int a=1; a<=9; a++)
            {
                for(int b=0; b<=9; b++)
                {
                    for(int c=0; c<=9; c++)
                    {
                        int sum=a+b+c;
                        int square=sum*sum;
                        proof=square%square;
                    }
                }
            }
            System.out.print(proof);
            
        }
    }
    proof=square%square;
    should be proof=abc(concantenated)%square; Then it needs to check if the remainder is anything but 0.
    Last edited by swirly; 02-03-2009 at 10:05 AM.
    Don't go to bed angry, stay awake and plot revenge.

  2. #2
    dbojan's Avatar
    dbojan is offline x10Hosting Member dbojan is an unknown quantity at this point
    Join Date
    Nov 2008
    Location
    Bosnia and Herzegovina
    Posts
    99

    Re: Java

    Do you mean something like this:
    int concatenated=a*100+b*10+c;
    ?

  3. #3
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: Java

    Code:
    proof=(a*100+b*10+c)%square;
    If I understand what you mean.
    It's only that easy because you're working with numbers between 0 and 9. Otherwise you should use logarithmic stuff to determine the length of the numbers etc.
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  4. #4
    gkglock is offline x10Hosting Member gkglock is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    4

    Re: Java

    If your looking to concatenate integers it would probably be best to use the StringBuilder class. Then convert the string with the parseint methnod.

  5. #5
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: Java

    Quote Originally Posted by gkglock View Post
    If your looking to concatenate integers it would probably be best to use the StringBuilder class. Then convert the string with the parseint methnod.
    You could, but it's much more mathematical to do it with logarithms ;)
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

+ Reply to Thread

Similar Threads

  1. Java
    By Rhianna in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 03-07-2009, 06:22 PM
  2. Anfy Java Applet Online problems
    By Tharu in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 08-02-2008, 09:05 PM
  3. creating a starfield with a java
    By intertec in forum Tutorials
    Replies: 0
    Last Post: 02-08-2008, 01:08 AM
  4. Java Tutorial for Beginners.
    By satheesh in forum Tutorials
    Replies: 0
    Last Post: 10-27-2007, 06:40 PM
  5. Java?
    By pensoftware in forum Free Hosting
    Replies: 2
    Last Post: 10-15-2005, 01:18 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
x10hosting free hosting for the masses
dedicated servers