我试图用java写一个简单的计算器,因为我想学习这门语言。但我无法计算“C”变量。请帮忙。怎么了?
import java.util.*;
//Simple calculator
public class calc
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
double a, b, c;
System.out.print("Write first number");
a = in.nextDouble();
System.out.print("and write second");
b = in.nextDouble();
System.out.print("Choose the operation 1.Addition 2.Subtraction >Please write the number of operation ");
double somethin = in.nextDouble();
int addition = 1;
int subtraction = 2;
if (somethin >= addition)
{
c = a + b;
}
else if (somethin >= subtraction)
{
c = a - b;
}
{
System.out.println(c);
}
}
}