Hey guys, made a basic calculator, with the following code:
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class CalcApp extends Object
{
public static void main(String[] argStrings) throws Exception
{
Scanner calcInput = new Scanner (System.in);
System.out.printf ("Please enter your first number\n");
int firstInt = calcInput.nextInt();
System.out.printf ("Please enter your second number\n");
int secondInt = calcInput.nextInt();
System.out.printf ("Your second number is " + secondInt + "\n");
System.out.printf ("Your first number is " + firstInt + "\n");
System.out.printf ("Please enter your operator (1 = +) (2 = -) (3= /) \n");
int calcOperatorInput = calcInput.nextInt();
switch (calcOperatorInput)
{
case 1:
System.out.println("Your Operator is (+)");
int calcAnswer = ( firstInt + secondInt );
break;
case 2:
System.out.println("Your Operator is (-)");
int calcAnswer = ( firstInt - secondInt );
break;
case 3:
System.out.println("Your Operator is (/)");
int calcAnswer = ( firstInt / secondInt );
break;
default:
System.out.println("Sorry, You must enter a number beetween 1-3");
break;
}
System.out.printf ("Your answer is"+ calcAnswer +"\n");
}
}
Also we have the following error's
First of all calcAnswer is already defined, and also it cannot find symbol.
Thanks for the help