I really need help, I have this project due in 6 hours... i needed to implement a simple menu system and one of the choices was to get two user defined integers and define them in integer objects. I cannot get how to do this!
below is the header of my code excluding the menu choices and the other 3 menus
this line --> return diffEnt1.compareTo(diffEnt2); is what I am having trouble with, i dont know what i need to be calling, or is there an easier way to subtract the two numbers?
I apologize as I am very new to this...
thanks in advance!!
""
import java.util.*;
class p2 {
public static void main(String args[]) {
int number;
Scanner scanner = new Scanner(System.in);
(LINE BREAKS......)
if (number == 4){
int diffEnt1, diffEnt2, diffOut;
diffEnt1 = new Integer(2);
diffEnt2 = new Integer(2);
System.out.println("This function will find the difference of two integers");
System.out.println("Please enter the first integer: ");
diffEnt1 = scanner.nextInt();
System.out.println("Please enter the second integer: ");
diffEnt2 = scanner.nextInt();
System.out.println();
System.out.println("You want to find the difference of " + diffEnt1 + " and " + diffEnt2);
return diffEnt1.compareTo(diffEnt2);
System.out.println("The difference of " + diffEnt1 + " and " + diffEnt2 + " is " + diffOut);
}
below is the header of my code excluding the menu choices and the other 3 menus
this line --> return diffEnt1.compareTo(diffEnt2); is what I am having trouble with, i dont know what i need to be calling, or is there an easier way to subtract the two numbers?
I apologize as I am very new to this...
thanks in advance!!
""
import java.util.*;
class p2 {
public static void main(String args[]) {
int number;
Scanner scanner = new Scanner(System.in);
(LINE BREAKS......)
if (number == 4){
int diffEnt1, diffEnt2, diffOut;
diffEnt1 = new Integer(2);
diffEnt2 = new Integer(2);
System.out.println("This function will find the difference of two integers");
System.out.println("Please enter the first integer: ");
diffEnt1 = scanner.nextInt();
System.out.println("Please enter the second integer: ");
diffEnt2 = scanner.nextInt();
System.out.println();
System.out.println("You want to find the difference of " + diffEnt1 + " and " + diffEnt2);
return diffEnt1.compareTo(diffEnt2);
System.out.println("The difference of " + diffEnt1 + " and " + diffEnt2 + " is " + diffOut);
}