當前位置:編程學習大全網 - 網站源碼 - Java等價操作源代碼

Java等價操作源代碼

while(true){

System.out.print("請輸入:例如1+2,4/6 ... ");

Scanner s =新掃描儀(system . in);

string str = s . next();

if(str.length()==3){

嘗試{

float a = float . parse float(str . substring(0,1));

float b = float . parse float(str . substring(2,3));

String c = str.substring(1,2);

switch (c.hashCode()) {

案例43:

system . out . println(a+"+"+b+" = "+(a+b));

打破;

案例45:

system . out . println(a+"+"+b+" = "+(a-b));

打破;

案例42:

system . out . println(a+"+"+b+" = "+(a * b));

打破;

案例47:

system . out . println(a+"+"+b+" = "+(a/b));

打破;

默認值:

打破;

}

} catch(異常e) {

System.out.println("輸入錯誤");

}

}否則{

System.out.println("輸入錯誤");

}

}

給它壹個好的評價!謝謝妳

  • 上一篇:幾千股跌了好幾次。為什麽千股沒有漲停?
  • 下一篇:源碼資本什麽水平
  • copyright 2024編程學習大全網