q6-6まで完了
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* PTra05_01.java
|
||||
* 作成 Rhizome
|
||||
|
||||
@@ -29,6 +29,27 @@ public class PTra05_02 {
|
||||
* 変数choiceの値が % の場合 -> num1 を num2 で 割った余り を出力
|
||||
* 変数choiceの値が 上記以外 の場合 -> 計算に失敗しました を出力
|
||||
*/
|
||||
switch(choice) {
|
||||
case "+" :
|
||||
System.out.println(num1 + num2);
|
||||
break;
|
||||
case "-" :
|
||||
System.out.println(num1 - num2);
|
||||
break;
|
||||
case "*":
|
||||
System.out.println(num1 * num2);
|
||||
break;
|
||||
case "/":
|
||||
System.out.println(num1 / num2);
|
||||
break;
|
||||
case"%":
|
||||
System.out.println(num1 % num2);
|
||||
default:
|
||||
System.out.println("計算に失敗しました");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,5 +43,32 @@ public class PTra05_03 {
|
||||
// TODO 予想が当たった場合は「あなたの勝ちです」、外れた場合は「あなたの負けです」を出力してください。
|
||||
// ※ H か L 以外の文字が入力された場合は、「不正な値が入力されました」と出力してください。
|
||||
|
||||
String result;
|
||||
switch (judgement) {
|
||||
case "H":
|
||||
if (myCard >= dealerCard) {
|
||||
System.out.println("あなたの勝ちです");
|
||||
} else if (myCard < dealerCard) {
|
||||
System.out.println("あなたの負けです");
|
||||
}
|
||||
break;
|
||||
// }else if(myCard == dealerCard) {
|
||||
// System.out.println();
|
||||
// }
|
||||
|
||||
case "L":
|
||||
if (myCard <= dealerCard) {
|
||||
System.out.println("あなたの勝ちです");
|
||||
} else if (myCard > dealerCard) {
|
||||
System.out.println("あなたの負けです");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("不正な値が入力されました");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user