Originally Posted by

**Tracy22**
Can someone please tell me how to keep this program the same with the 3 functions but instead of the sum of the 2 numbers I need it to tell me if the 1st number is <> or equal to the second number? I cant figure out how to change it in the 2nd and 3rd function so it returns it and displays it. I've been stuck for hours on something that is probaly simple.

public static void main(String[] args) {
int num3;
int num4;
int sum;
//get the first number
num3 = getNum();
//get the second number
num4 = getNum();
//get the sum of the two numbers
sum = getSum(num3, num4);
//Show the result
showResult(sum);
}
//Read a number from the keyboard and return it.
public static int getNum()
{
//for getting an input from the keyboard
Scanner input = new Scanner(System.in);
//An inputted number will be stored in this variable
int num;
//prompt the user to enter a number
System.out.println("Enter a number: ");
//get a number from the keyboard and it is stored in num
num = input.nextInt();
//send back the inputted number
return num;
}
//
public static int getSum(int num3, int num4)
{
//the sum will be stored in this variable
int sum;
//add num1 and num2 and the result is stored in sum
sum = num3 + num4;
//send back the sum
return sum;
}
//Show the result
public static void showResult(int sum)
{
System.out.println("The sum of the two numbers is " + sum);
System.out.println("Thank you");
}

Actually, I'm not sure if you're trying to get the same sum that you got in method getSum(int i, int j) and showing it in show result. If so, you'll need to have the two values that you gave it as parameters when you put, getSum(), which you should do if the sum you're passing it is supposed to be the same sum that you're returning from getSum().

If so, you could do this:

public static void showResult(int num1, int num2)
{
System.out.println("The sum of " + num1 + " and " + num2 + " is " + getSum(num1,num2));
System.out.println("Thank you");
}