Need help understanding how to make this function properly. It will only run as "New" not "Void()" and when I get to the Scan.line it crashes. I also have to learn how to plot linear functions such as y = mx + b and such. This is my first time doing a project so big and I am yearning to really develop my analytic thinking skills in order to progress as a programmer. Please some help would much be appreciated.
import java.util.Scanner;
public static class Calculator
{
int Number1;
int Number2;
String Operation;
int Final;
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println ("Enter your first number: ");
Number1 = scan.nextInt();
System.out.println ("Number 1: " + Number1 + " Number 2: " + Number2);
System.out.println ("Ener your second number: ");
Number2 = scan.nextInt();
System.out.println ("Number1: " + Number1 + " Number 2: " + Number2);
System.out.println ("Enter numericle operation you wish to preform: ");
Operation = scan.nextLine();
if ( Operation == "+" )
{
Final = (Number1 + Number2);
System.out.print("Ans: " + Final);
}
if ( Operation == "-" )
{
Final = (Number1 - Number2);
System.out.print("Ans: " + Final);
}
if ( Operation == "*" )
{
Final = (Number1 * Number2);
System.out.print("Ans: " + Final);
}
if ( Operation == "/" )
{
Final = (Number1 / Number2);
System.out.print("Ans: " + Final);
}
}
}