# Thread: 74 year old novice needs help

1. Member
Join Date
Aug 2015
Posts
1
Rep Power
0

## 74 year old novice needs help

Java Code:
```import java.math.BigInteger;
import java.util.Scanner;
public class abc;
{
public static void main (String[] args)
{
/*  big integer declarations */
BigInteger i1, i2, i3;
i1 = new BigInteger (“111222333444555”);
i2 = new BigInteger (“111000111000222”);
/*  Boolean declarations */
Boolean boo1 = true,  boo2 = false;
String myStr  =  “Result of addition is “  +i3;
System.out.println(myStr);
/* subtraction */
i3  =  i1.subtract(i2);
String myStr1 = “Result of subtraction is “  +i3;
System.out.println(myStrl);
/* is equal to */
if (i1.equals(i2))
{
String myStr2 =  i1+”equals BigInteger”+i2”is”+bool;
System.out.println(myStr2);
}
else
{
String myStr2 =  i1+”equals BigInteger”+i2+”is”+boo2;
System.out.println(myStr2);
}
/*  is not equal to  */
if(!i1.equals(i2))
{
String myStr2 =  i1+”not equals BigInteger”+i2+”is”+boo1;
System.out.println(myStr2);
}
else
{
String myStr2 =  i1+”not equals BigInteger”+i2+”is”+boo2;
System.out.println(myStr2);
}
/*  compareTo method is used to find greater than/less than values */
int b3 = i1.compareTo(i2);
String s1 = i1+ “ values is equal to “ +i2;
String s2 = i1+ “ is greater than “ +i2;
String s3 = i2+ “ is greater than “ +i1;
if( b3 == 0 )
System.out.println( s1 );
else if( b3 == 1 )
System.out.println( s2 );

else if( b3 == -1 )
System.out.println( s3 );
}
}```
Last edited by JosAH; 08-25-2015 at 08:07 AM. Reason: aded [code] ... [/code] tags

2. ## Re: 74 year old novice needs help

Please go through Forum Rules, with particular reference to the third paragraph. Then check out BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

db

3. ## Re: 74 year old novice needs help

Also, you posted a wall of code but neglected to ask a question.

db

4. ## Re: 74 year old novice needs help

I added code tags for you, but the forum software ruined it again (it can't handle comments very well); but more important is: what is your question? From the code I can see that you wan to experiment with BigIntegers, but doesn't it work? Doesn't it compile?

kind regards,

Jos

5. Member
Join Date
Aug 2015
Location
Northern California
Posts
31
Rep Power
0

## Re: 74 year old novice needs help

First problem is those are not quotation marks you need to specifically use "
Since I don't know what you are trying to do I can not help you with your code very well. I usually do not post the answers inside a working piece of code because it is bad teaching. But at your age I think you are doing really well so I added comments to any errors I thought you may have made. Please have a look at what I changed.

2. Look for my comments on the remaining items I changed, for example the first one is /** Removed ; after class name */ ////EDIT////
Java Code:
```package teach;

import java.math.BigInteger;
import java.util.Scanner;
/** Removed ; after class name */ ////EDIT////
public class abc
{
public static void main (String[] args)
{
/*  big integer declarations */
BigInteger i1, i2, i3;
i1 = new BigInteger ("111222333444555");
i2 = new BigInteger ("111000111000222");
/*  Boolean declarations */
Boolean boo1 = true,  boo2 = false;
String myStr  =  "Result of addition is "  +i3;
System.out.println(myStr);
/* subtraction */
i3  =  i1.subtract(i2);
String myStr1 = "Result of subtraction is "  +i3;

System.out.println(myStr1);
/* is equal to */
if (i1.equals(i2))
{
/** Added a + after i2 variable */ ////EDIT////
String myStr2 =  i1+"equals BigInteger" +i2 +" is" +boo1;
System.out.println(myStr2);
}
else
{
String myStr2 =  i1+"equals BigInteger"+i2+"is"+boo2;
System.out.println(myStr2);
}
/*  is not equal to  */
if(!i1.equals(i2))
{
String myStr2 =  i1+"not equals BigInteger"+i2+"is"+boo1;
System.out.println(myStr2);
}
else
{
String myStr2 =  i1+"not equals BigInteger"+i2+"is"+boo2;
System.out.println(myStr2);
}
/*  compareTo method is used to find greater than/less than values */
int b3 = i1.compareTo(i2);
String s1 = i1+ " values is equal to " +i2;
String s2 = i1+ " is greater than " +i2;
String s3 = i2+ " is greater than " +i1;
if( b3 == 0 )
System.out.println( s1 );
else if( b3 == 1 )
System.out.println( s2 );

else if( b3 == -1 )
System.out.println( s3 );
}
}```
By the way I think you are doing extremely well keep it up
Last edited by devMichaelSmith; 08-25-2015 at 08:53 AM.