i am writing a program for my java class and have to create a calculator, i got the calculator to work for two numbers but can't get it to do more than two numbers and it needs to. any help will be greatly appreciated. If you take out the tnum the calculator will process the two numbers.
import java.util.Scanner;
public class MainClass
{
public static void main( String args[] )
{
Scanner input = new Scanner( System.in );
String operator = "+,-,*,/";
double fnum = 0;
double snum = 0;
double answer = 0;
double tnum = 0;
System.out.print( "Enter first integer: " );
fnum = input.nextDouble();
System.out.println("enter operator");
operator = input.next();
System.out.print( "Enter second integer: " );
snum = input.nextDouble();
System.out.println("enter operator");
operator = input.next();
System.out.print( "Enter third integer: " );
snum = input.nextDouble();
if (operator.equals("+"))
{
answer = fnum + snum + tnum;
System.out.println(fnum + snum + tnum);
}
else if (operator.equals("-"))
{
answer = fnum - snum - tnum;
System.out.println(fnum - snum - tnum);
}
else if(operator.equals("*"))
{
answer = fnum * snum * tnum;
System.out.println(fnum * snum * tnum);
}
else if(operator.equals("/"))
{
answer = fnum / snum / tnum;
System.out.println(fnum / snum / tnum);
}
System.out.println(answer);
}
}