import java.io.BufferedReader;
import java.io.InputStreamReader;
public class App
{
public static void main( String[] args ) throws Exception
{
enter code here
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println( "Enter 2 numbers:" );
float num1 = Float.parseFloat(br.readLine());
float num2 = Float.parseFloat(br.readLine());
System.out.println("Select option : 1.Addition 2.Substraction 3.Multiplication 4.Division");
int option = Integer.parseInt(br.readLine());
switch(option) {
case 1:System.out.print("result: "+(num1+num2));break;
case 2:System.out.print("result: "+(num1-num2));break;
case 3:System.out.print("result: "+(num1*num2));break;
case 4:System.out.print("result: "+(num1/num2));break;
}
}
}
我在 java 中有简单的计算器代码,需要在这个 Calcualtor 程序上实现 solid、kiss、dry 和 yagin 原则。