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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
6
Question06-for/.classpath
Normal file
6
Question06-for/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
Question06-for/.gitignore
vendored
Normal file
1
Question06-for/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
Question06-for/.project
Normal file
17
Question06-for/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question06-for</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -8,5 +8,9 @@ public class PTra06_01 {
|
||||
public static void main(String[] args) {
|
||||
// TODO for文を使って0から99までの整数を順にコンソールに出力してください。
|
||||
|
||||
for(int i = 0; i <= 99; i++){
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ public class PTra06_02 {
|
||||
/*
|
||||
* ■■■■■
|
||||
*/
|
||||
for(int i = 0; i < 5; i++) {
|
||||
System.out.print("■");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ public class PTra06_03 {
|
||||
|
||||
// iが0から100になるまで繰り返しを行います
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
if(i % 2 == 0){
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
|
||||
// TODO iが偶数の時だけ、iの値を出力してください
|
||||
|
||||
|
||||
@@ -14,6 +14,18 @@ public class PTra06_04 {
|
||||
* ④ 上記のいずれにも当てはまらない場合はiの値をそのまま出力する
|
||||
*/
|
||||
for(int i = 1;i < 50;i++) {
|
||||
if(i % 3 == 0) {
|
||||
System.out.println("fizz"); //①処理
|
||||
}
|
||||
if(i % 5 == 0) {
|
||||
System.out.println("buzz"); //②処理
|
||||
}
|
||||
if(i % 3 == 0 && i % 5 == 0) {
|
||||
System.out.println("fizzbuzz"); //③処理
|
||||
}
|
||||
else {
|
||||
System.out.println(i); //④処理
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,12 @@ public class PTra06_05 {
|
||||
// TODO 値が2の場合は出力しないようにしてください。
|
||||
// ※ continueを用いてください。
|
||||
for(int i = 0;i < 10;i++) {
|
||||
randomNumber = random.nextInt(3);
|
||||
|
||||
|
||||
randomNumber = random.nextInt(3);{
|
||||
if(randomNumber == 2) {
|
||||
continue;
|
||||
}
|
||||
// System.out.println(randomNumber);
|
||||
}
|
||||
System.out.println(randomNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
public class PTra06_06 {
|
||||
public static void main(String[] args) {
|
||||
int rows = 5;
|
||||
// TODO for文を使って以下の出力結果が出るようなプログラムを作成してください。
|
||||
/*
|
||||
* ■■■■■
|
||||
@@ -14,7 +15,13 @@ public class PTra06_06 {
|
||||
* ■■■■■
|
||||
* ■■■■■
|
||||
*/
|
||||
|
||||
for(int i = 0; i < rows; i++) {
|
||||
for(int j = 0; j < rows; j++) {
|
||||
System.out.print("■");
|
||||
}
|
||||
// for(int i = 0; i <5; i++) {
|
||||
System.out.println("■");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//for(int i = 0; i <5; i++) {
|
||||
Reference in New Issue
Block a user