10 Commits

Author SHA1 Message Date
920c1d5303 q6-6まで完了 2026-09-17 16:39:23 +09:00
bac3c76248 q5-1完了 2026-09-11 16:47:58 +09:00
6dcc784838 q4-5まで完了 2026-09-11 16:39:12 +09:00
2c25236ae7 q4-1からq4-4まで完了 2026-09-11 16:05:20 +09:00
eb3936ce2d q3-4完了 2026-09-11 15:31:20 +09:00
1701ab4e84 q3-1からq3-3まで完了 2026-09-11 15:11:18 +09:00
a6152d2a13 q2-5からq2-8まで完了 2026-09-11 14:37:22 +09:00
f74b2041e2 q2-1からq2-4まで完了 2026-09-11 13:46:07 +09:00
2b2555f8e7 q8-9まで完了 2026-09-11 13:32:46 +09:00
d705f3d6ee q1-7まで完了 2026-09-11 13:17:33 +09:00
59 changed files with 380 additions and 261 deletions

1
.gitignore vendored
View File

@@ -24,4 +24,3 @@
hs_err_pid*
replay_pid*
/bin/

View 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
Question01-StartProgram/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/bin/

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question01-StartProgram</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>

View File

@@ -6,9 +6,9 @@
*/
public class PTra01_01 {
public static void main(String[] args) {
System.out.println("Hello,world");
//TODO Hello,world と出力してください
System.out.println("Hello,world");
}
}

View File

@@ -8,12 +8,12 @@ public class PTra01_02 {
public static void main(String[] args) {
// TODO 11行目のコメントを単一行コメントにしてコンパイルエラーが出ないようにしてください
// ここをコメントアウトする
//ここをコメントアウトする
// TODO 14行目 ~ 16行目を複数行コメントにしてコンパイルエラーが出ないようにしてください
// ここをコメントアウトする
// ここをコメントアウトする
// ここをコメントアウトする
System.out.println("comment out done");
//ここをコメントアウトする
//ここをコメントアウトする
//ここをコメントアウトする
}
}

View File

@@ -6,16 +6,12 @@
*/
public class PTra01_03 {
public static void main(String[] args) {
String string;
// TODO 文字列型の変数 str を宣言してください。
String comment;
String str = "こんにちは";
// TODO str に こんにちは を代入してください
comment = "こんにちは";
System.out.println(str);
// TODO str の値を出力してください
System.out.println(comment);
}
}

View File

@@ -6,12 +6,10 @@
*/
public class PTra01_04 {
public static void main(String[] args) {
int number = 10;
// TODO 数値型の変数 number を 10 で初期化してください。
int number = 10;
System.out.println(number);
// TODO number の値を出力してください
System.out.println(number);
}
}

View File

@@ -6,13 +6,10 @@
*/
public class PTra01_05 {
public static void main(String[] args) {
char ch = 'A';
// TODO char型の変数 ch を A で初期化してください。
char ch = 'A';
System.out.println(ch);
// TODO ch の値を出力してください
System.out.println(ch);
}
}

View File

@@ -6,12 +6,11 @@
*/
public class PTra01_06 {
public static void main(String[] args) {
boolean bo = true;
// TODO boolean型の変数 bo を true で初期化してください。
boolean bo = true ;
System.out.println(bo);
// TODO bo の値を出力してください
System.out.println(bo);
}
}

View File

@@ -6,11 +6,10 @@
*/
public class PTra01_07 {
public static void main(String[] args) {
long lo = 1000000000000L;
// TODO long型の変数 lo を 1000000000000 で初期化してください。
long lo = 1000000000000L;
System.out.println(lo);
// TODO lo の値を出力してください
System.out.println(lo);
}
}

View File

@@ -6,12 +6,10 @@
*/
public class PTra01_08 {
public static void main(String[] args) {
float fl = 3.14f;
// TODO float型の変数 fl を 3.14 で初期化してください。
float fl = 3.14f;
System.out.println(fl);
// TODO fl の値を出力してください
System.out.println(fl);
}
}

View File

@@ -6,43 +6,40 @@
*/
public class PTra01_09 {
public static void main(String[] args) {
// TODO 基本型8種類の変数を宣言します(変数名は自分できめてOKです)
// 整数型
byte by;
short sh;
int age;
long lo;
// 浮動小数点数型(小数)
float fl;
double dou;
// 文字型
char cha;
// 真偽値型
boolean boo;
// String string;
// int number;
// char cha;
// double doubl;
// Boolean bool;
byte b;
short short1;
int int1;
long long1;
float float1;
double double1;
char char1;
boolean boolean1;
// TODO 基本型8種類の変数を宣言します(変数名は自分できめてOKです)
b = 100;
short1 = 30000;
int1 = 101;
long1 = 1011L;
float1 = 10111.0f;
double1 = 1012.00;
char1 ='a' ;
boolean1 = true;
// TODO 宣言した変数に、値を代入してください(代入する値はなんでもOKです)
by = 10;
sh = 3;
age = 27;
lo = 123456789L;
fl = 123.333f;
dou =1.234;
cha ='H';
boo = true;
System.out.println(b);
System.out.println(short1);
System.out.println(int1);
System.out.println(long1);
System.out.println(float1);
System.out.println(double1);
System.out.println(char1);
System.out.println(boolean1);
// TODO それぞれの変数の中身を出力してください
System.out.println(by);
System.out.println(sh);
System.out.println(age);
System.out.println(lo);
System.out.println(fl);
System.out.println(dou);
System.out.println(cha);
System.out.println(boo);
}
}

View 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
Question02-Expressions/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/bin/

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question02-Expressions</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>

View File

@@ -13,25 +13,17 @@ public class PTra02_01 {
int div;
int rem;
int a = 6;
int b = 2;
int c= 17;
int d = 5;
sum = 6 + 2;
// TODO 6+2を計算して結果を変数sumに代入してください
sum = (a+b);
diff = 6 - 2;
// TODO 6-2を計算して結果を変数diffに代入してください
diff = (a-b);
mulch = 6 * 2;
// TODO 6×2を計算して結果を変数mulchに代入してください
mulch= (6*2);
div = 6 / 2;
// TODO 6÷2を計算して結果を変数divに代入してください
div = (6/2);
rem = 17 % 5;
// TODO 17÷5の余りを計算して変数remに代入してください
rem = (c%d);
// 各変数の表示(編集しないでください)
// ※ 8, 4, 12, 3, 2の順で表示されれば正解です

View File

@@ -10,9 +10,9 @@ public class PTra02_02 {
String firstName = "太郎";
String lastName = "山田";
System.out.println(lastName + firstName);
// TODO 苗字と名前をつなげて山田太郎と出力してください。
// ※ System.out.printlnを使うのは1回だけです。
System.out.println((firstName+lastName));
}

View File

@@ -8,10 +8,9 @@ public class PTra02_03 {
public static void main(String[] args) {
int num = 10;
num = num + 5;
// TODO numに5を足した値をnumに代入してください
num = num +5;
// numの値を出力します(編集しないでください)。
// ※ 15と出力されれば正解です。
System.out.println(num);

View File

@@ -9,10 +9,10 @@ public class PTra02_04 {
public static void main(String[] args) {
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
// ※数値リテラル部分は編集しないでください
int sum = (int) (10 + 3.14);
double sum = 10 + 3.14;
// ※以下は編集しないでください。13.14と出力されていれば正解です
System.out.println((double)sum);
System.out.println(sum);
}

View File

@@ -9,7 +9,8 @@ public class PTra02_06 {
public static void main(String[] args) {
// 以下のプログラムを実行すると割り算の結果の小数点以下が切り捨てられてしまいます。
// TODO 切り捨てられないように修正してください。
System.out.println((double)9/2);
double result = (double) 9 / 2;
System.out.println(result);
}

View File

@@ -8,10 +8,11 @@ public class PTra02_07 {
public static void main(String[] args) {
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
// ※数値リテラル部分は編集しないでください
int num =(int) 1.0;
int num = (int)1.0;
// ※ 以下は編集しないでください。1と出力されていれば正解です
System.out.println(num);
System.out.println (num);
}
}

View File

@@ -15,19 +15,14 @@ public class PTra02_08 {
double taxRate = 0.08;
// TODO 買い物した際の残金計算をします。
double price1 = price + (price * taxRate);
// TODO 所持金から価格を引いた値を、買い物後の所持金として再代入してください。
// ※消費税を考慮してください。税込み商品価格の端数は切り捨てとします。
int taxinpc =(int) (price+(price*taxRate));
money = money-taxinpc;
money = money - ((int)price1);
// 残金の表示部分です。編集しないでください
System.out.println("残金は" + money + "円です。");
//自分用の税込お値段チェック
System.out.println("税込値段"+ taxinpc);
}
}

6
Question03-if/.classpath Normal file
View 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
Question03-if/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/bin/

17
Question03-if/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question03-if</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>

View File

@@ -6,13 +6,12 @@
*/
public class PTra03_01 {
public static void main(String[] args) {
// TODO int型の変数numを宣言し、100で初期化してください
int num = 100;
// TODO「変数numが100である」という条件式を追加してください
if (num ==100) {
int num = 100;
// TODO int型の変数numを宣言し、100で初期化してください
//boolean bool = (100 == num);
// TODO「変数numが100である」という条件式を追加してください
if (num == 100) {
System.out.println("条件に合致しました");
}
}

View File

@@ -7,15 +7,16 @@
public class PTra03_02 {
public static void main(String[] args) {
// TODO int型の変数numを宣言し、65で初期化してください
int num = 65;
int num = 65;
// TODO 変数numの値が65以上の場合は「合格です」と出力し、それ以外であれば「不合格です」を出力してください
if (num>65) {
System.out.println("あなたの点数は"+num+"合格です");
}else {
System.out.println("あなたの点数は"+num+"不合格です");
if(num >= 65) {
System.out.println("合格です");
}
// ※ 合格です と表示されれば正解
else {
System.out.println("不合格です");
}
// ※ 合格です と表示されれば正解
}
}

View File

@@ -7,9 +7,9 @@
public class PTra03_03 {
public static void main(String[] args) {
int num = 10;
//num = (int)(num / 2 && num / 5);
// TODO numが 2で割り切れる かつ 5で割り切れるという条件式を記述してください
if (num /2==5) {
if (num % 2 == 0&& num % 5 ==0) {
System.out.println(num + "は2でも5でも割り切れます。");
}
}

View File

@@ -1,12 +1,14 @@
/*
/*im
* PTra03_04.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra03_04 {
public static void main(String[] args) {
System.out.println("降水確率を入力してください。(数字のみ)");
//Scanner scaner = new Scanner(System.in);
// キーボードから入力した数値を変数 num に代入します
int num = new java.util.Scanner(System.in).nextInt();
@@ -14,21 +16,22 @@ public class PTra03_04 {
// TODO 以下の条件に沿ったプログラムを記述してください
/*
* 入力された数値によって以下のように出力してください。
* 変数numの値が 75以上 の場合 -> 雨が降る確率が高いで
* 変数numの値が 75以上 の場合 -> 雨が降る確率が高いです
* 変数numの値が 30~74 の場合 -> 雨が降るかもしれないです
* 変数numの値が 30未満 の場合 -> 雨はまず降らないでしょう
*
* ※ 変数numの値が 0より小さい または 100より大きい場合は「不正な値が入力されました」と出力してください。
*/
if( (num<0) || (num>100)) {
System.err.println("不正な値が入力されました");
if(num >= 75 && num <= 100){
System.out.println("雨が降る確率が高いです。");
}if(30 <= num && num <= 74) {
System.out.println("雨が降るかもしれないです");
}if(num < 30) {
System.out.println("雨はまず降らないでしょう");
}else if(num < 0 || num > 100) {
System.out.println("不正な値が入力されました");
}
}else if ((num>30) && (num<75)) {
System.err.println("雨が降るかもしれないです");
}else if (num>=75) {
System.out.println("雨が降る確率が高いで");
}else {
System.err.println("雨はまず降らないでしょう");
}
}
}

View 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
Question04-while/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/bin/

17
Question04-while/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question04-while</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>

View File

@@ -16,13 +16,17 @@ public class PTra04_01 {
// 以下のwhile文は0~9のランダムな値をコンソールに出力する処理を無限に繰り返します。
// TODO while文の条件を修正して5が出力されたら繰り返しを止めるようにしてください。
while(true) {
// 0~9のランダムな値を生成
if (randomNumber==5) {
break;
}
randomNumber = random.nextInt(10);
// 生成した値をコンソールに出力
System.out.println(randomNumber);
boolean isOver = (randomNumber == 5);
if(isOver) {
break;
}
}
}

View File

@@ -15,19 +15,16 @@ public class PTra04_02 {
* 繰り返しの中でnumを2倍した数値をnumに代入してください。
* ※ 繰り返しにはwhile文を用いてください
*/
while(num <=1000) {
while(true) {
// num++;
num *=2;
num = (num * 2);
boolean isToom = (num >= 1000);
if(isToom) {
break;
}
System.out.println(num);
if (num>1000) {
System.out.println("終了");
}
}
}
}

View File

@@ -18,12 +18,10 @@ public class PTra04_03 {
// ※ while文の条件は変更せずにbreak文を使ってください。
while(true) {
// 0~9のランダムな値を生成
if(randomNumber==5) {
break;
}
randomNumber = random.nextInt(10);
// 生成した値をコンソールに出力
System.out.println(randomNumber);
}
}

View File

@@ -1,4 +1,3 @@
/*
* PTra04_04.java
* 作成 Rhizome
@@ -19,15 +18,15 @@ public class PTra04_04 {
Random random = new Random();
// TODO 双六の総コマ数としてint型の変数mapを宣言し、50を代入してください。
int map =50;
int map = 50;
// TODO 現在までの進んだコマ数としてint型の変数progressを宣言し、0を代入してください。
int progress = 0;
int progress = 0;
System.out.println("===== START =====");
// TODO 変数mapとprogressを用いて、ゴールするまで繰り返すようにwhile文の条件を記述してください。
while (progress < map) {
while(true) {
// 入力を促すメッセージを出力し、エンターキーが押されるのを待ちます。
System.out.println("Enterキーを押してください。さいころをふります。");
scanner.nextLine();
@@ -37,16 +36,20 @@ public class PTra04_04 {
// TODO 変数diceを用いて、"#の目が出ました。"というメッセージを出力してください。
// ※ #には変数diceの値が入ります。
System.out.println(progress+"の目が出ました");
System.out.println(dice + "の目が出ました。");
// TODO 変数progressに変数diceの値を加算してください。
progress += dice;
progress = progress + dice;
// TODO まだゴールしていない場合は"残りのマスは#マスです。"というメッセージを出力してください。
// ※ #には双六の残りのマス数が入ります。
if (progress < map) {
System.out.println("残りのマスは"+(map - progress)+"マスです。");
}
if(progress < 50) {
System.out.println("残りのマスは" + (map - progress) + "マスです。");
}else if(progress >= 50){
break;
}
}

View File

@@ -24,36 +24,55 @@ public class PTra04_05 {
while(!winFlag) {
int playerHand;
int npcHand;
// プレイヤーに出す手を選ばせる
// ※ 数値でな い入力は考慮していません(エラーになります)
// ※ 数値でない入力は考慮していません(エラーになります)
System.out.println("じゃんけんを行います。");
System.out.println("あなたの出す手を入力してください");
System.out.println("0:グー, 1:チョキ, 2:パー");
playerHand = Integer.parseInt(scanner.nextLine());
// TODO 選ばれた手を出力してください(0なら"あなたはグーを出しました"等)
String[]hand = {"グー", "チョキ", "パー"}; //for changing number to select for menume (menune arry[number array])
System.out.println("あなたは"+hand[playerHand] +"を出しました"); //here will be change number to menue
if(playerHand ==0) {
System.out.println("あなたはグーを出しました");
}if(playerHand == 1) {
System.out.println("あなたはチョキを出しました。");
}else if(playerHand == 2){
System.out.println("あなたはパーを出しました。");
}
// 対戦相手の手をランダムに選択する。
npcHand = random.nextInt(3);
// TODO 対戦相手の手を出力してください(0なら"相手はグーを出しました"等)
System.out.println("相手は"+hand[npcHand]+"を出しました");
// TODO じゃんけんの結果を出力し、プレイヤーが勝った場合はプログラムが終了するようにしてください。
if (playerHand== npcHand) {
System.out.println("equal");
}else if ((playerHand==0 && npcHand==1)||(playerHand==2 && npcHand==0)||(playerHand==1&&npcHand==2)){
System.out.println("win");
winFlag= true;
}else {
System.out.println(("over"));
if(npcHand ==0) {
System.out.println("相手はグーを出しました");
}if(npcHand == 1) {
System.out.println("相手はチョキを出しました。");
}else if(npcHand == 2){
System.out.println("相手はパーを出しました。");
}
// TODO じゃんけんの結果を出力し、プレイヤーが勝った場合はプログラムが終了するようにしてください。
String result;
if(playerHand == npcHand) {
result = "あいこです。";
}else if(
(playerHand == 0 && npcHand == 1)|| //プレイヤグー・相手チョキ
(playerHand == 1 && npcHand == 2)|| //チョキ・パー
(playerHand == 2 && npcHand == 0) //パー・チョキ
) {
result = "あなたの勝ち";
System.out.println("結果 : " + result);
break;
}else {
result = "あなたの負け";
}
System.out.println("結果 : " + result);
}
// 次のじゃんけんの前に改行しておく
System.out.println();
}
}
}

View 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
Question05-switch/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/bin/

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question05-switch</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>

View File

@@ -1,3 +1,4 @@
/*
* PTra05_01.java
* 作成 Rhizome
@@ -11,6 +12,7 @@ public class PTra05_01 {
// ランダムな数値をnumに代入します。範囲は 0 ~ 5 です。
int num = new java.util.Random().nextInt(6);
// TODO 以下の条件に沿ったプログラムを記述してください
// ※ switch文を使用してプログラムを記述してください
/*
@@ -20,30 +22,28 @@ public class PTra05_01 {
* 変数numの値が 2 の場合 -> あなたの運勢は「中吉」です
* 変数numの値が 3 の場合 -> あなたの運勢は「小吉」です
* 変数numの値が 4 の場合 -> あなたの運勢は「末吉」です
* 変数numの値が 5 の場合 -> あなたの運勢は「凶」です
* 変数numの値が 5 の場合 -> あなたの運勢は「末吉」です
*/
System.out.println(num);
switch (num) {
case 0:
switch(num) {
case 0 :
System.out.println("あなたの運勢は「大吉」です");
break;
case 1:
System.out.println("あなたの運勢は「吉」です");
break;
case 2:
case 1 :
System.out.println("あなたの運勢は「吉」です");
break;
case 2 :
System.out.println("あなたの運勢は「中吉」です");
break;
case 3:
case 3 :
System.out.println("あなたの運勢は「小吉」です");
break;
case 4:
case 4 :
System.out.println("あなたの運勢は「末吉」です");
break;
case 5:
System.out.println("あなたの運勢は「凶」です");
default:
case 5 :
System.out.println("あなたの運勢は「末吉」です");
break;
}
}
}

View File

@@ -17,10 +17,7 @@ public class PTra05_02 {
System.out.println("計算方法を選択してください");
// キーボードから入力した文字列を choice に代入します。
System.out.println("");
String choice = new java.util.Scanner(System.in).nextLine();
String[]result = {"+","-","*","/","%"};
// TODO 以下の条件に沿ったプログラムを記述してください
/*
@@ -32,25 +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);
switch(choice) {
case "+" :
System.out.println(num1 + num2);
break;
case "-" :
System.out.println(num1 - num2);
break;
case "*":
System.out.println(num1*num2);
System.out.println(num1 * num2);
break;
case "/":
System.out.println(num1/num2);
break;
case "%":
System.out.println(num1%num2);
System.out.println(num1 / num2);
break;
case"%":
System.out.println(num1 % num2);
default:
break;
System.out.println("計算に失敗しました");
}
}

View File

@@ -34,7 +34,7 @@ public class PTra05_03 {
String judgement = new java.util.Scanner(System.in).nextLine();
System.out.println("あなたのカードは" + myCard + "です");
// System.out.println("ディーラのカードは" + dealerCard + "です。");
System.out.println();
System.out.println("=========================================");
System.out.println(" 勝敗判定");
@@ -43,20 +43,23 @@ public class PTra05_03 {
// TODO 予想が当たった場合は「あなたの勝ちです」、外れた場合は「あなたの負けです」を出力してください。
// ※ H か L 以外の文字が入力された場合は、「不正な値が入力されました」と出力してください。
String result;
switch (judgement) {
case "H":
case "h":
if (myCard >= dealerCard) {
System.out.println("あなたの勝ちです");
} else {
} else if (myCard < dealerCard) {
System.out.println("あなたの負けです");
}
break;
// }else if(myCard == dealerCard) {
// System.out.println();
// }
case "L":
case "l":
if (myCard <= dealerCard) {
if (myCard <= dealerCard) {
System.out.println("あなたの勝ちです");
} else {
} else if (myCard > dealerCard) {
System.out.println("あなたの負けです");
}
break;
@@ -67,4 +70,5 @@ public class PTra05_03 {
}
}
}

View 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
View File

@@ -0,0 +1 @@
/bin/

17
Question06-for/.project Normal file
View 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>

View File

@@ -7,8 +7,10 @@
public class PTra06_01 {
public static void main(String[] args) {
// TODO for文を使って0から99までの整数を順にコンソールに出力してください。
for (int i = 0; i < 100; i++) {
System.out.println(i);
for(int i = 0; i <= 99; i++){
System.out.println(i);
}
}
}

View File

@@ -10,7 +10,7 @@ public class PTra06_02 {
/*
* ■■■■■
*/
for(int i =0; i<6; i++) {
for(int i = 0; i < 5; i++) {
System.out.print("■");
}
System.out.println();

View File

@@ -9,12 +9,12 @@ 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の値を出力してください
if(i%2==0) {
System.out.println(i);
}
}
}

View File

@@ -14,17 +14,19 @@ public class PTra06_04 {
* ④ 上記のいずれにも当てはまらない場合はiの値をそのまま出力する
*/
for(int i = 1;i < 50;i++) {
if ((i%3==0)&&(i%5==0)) {
System.out.println("fizzbuzzzzzzzzzzzzz");
}else if(i%3==0) {
System.out.println("fizz");
}else if(i%5==0) {
System.out.println("buzz");
}else {
System.out.println(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); //④処理
}
}
}

View File

@@ -17,13 +17,12 @@ public class PTra06_05 {
// TODO 値が2の場合は出力しないようにしてください。
// ※ continueを用いてください。
for(int i = 0;i < 10;i++) {
randomNumber = random.nextInt(3);
if(randomNumber==2) {
continue;
randomNumber = random.nextInt(3);{
if(randomNumber == 2) {
continue;
}
// System.out.println(randomNumber);
}
System.out.println(randomNumber);
}
}

View File

@@ -6,6 +6,7 @@
*/
public class PTra06_06 {
public static void main(String[] args) {
int rows = 5;
// TODO for文を使って以下の出力結果が出るようなプログラムを作成してください。
/*
* ■■■■■
@@ -14,14 +15,13 @@ public class PTra06_06 {
* ■■■■■
* ■■■■■
*/
for (int i=0; i<5;i++ ){
for(int r=0; r<4;r++) {
System.out.print("■");}
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++) {

View File

@@ -19,17 +19,7 @@ public class PTra06_07 {
* 8 16 24 32 40 48 56 64 72
* 9 18 27 36 45 54 63 72 81
*/
for (int i=1; i<=9;i++ ){
for(int r=1; r<=9;r++) {
System.out.print(i*r + " ");
}
System.out.println();
}
}
}
}

View File

@@ -7,14 +7,11 @@
public class PTra07_01 {
public static void main(String[] args) {
// TODO 要素数5のint型の配列を宣言してください
int []array = {1,3,5,7,9};
// TODO 宣言した配列に要素として1,3,5,7,9を設定してください
// TODO 配列の2番目の値を出力してください。
// ※ 3が表示されれば正解
System.out.println(array[1]);
}
}

View File

@@ -7,11 +7,9 @@
public class PTra07_02 {
public static void main(String[] args) {
// TODO int型の配列を宣言し、整数値1,10,100を入れて初期化してください
int []i = {1,10,100};
// TODO 配列の1番目と3番目を足した値を出力してください
// ※ 101 が出力されれば正解です。
System.out.println(i[0]+i[2]);
}
}

View File

@@ -15,8 +15,6 @@ public class PTra07_03 {
// TODO 配列arrayの全要素を順番に出力してください
// ※ 繰り返しを使用して記述すること
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}

View File

@@ -10,14 +10,7 @@ public class PTra07_04 {
// TODO 配列arrayに1から1000までの整数を順に入れてください
// ※ for文を用いて代入を行うこと
for(int i= 0; i < array.length;i++) {
array[i]=i+1;
}
// TODO 配列arrayの全要素を順番に出力してください
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}

View File

@@ -17,10 +17,8 @@ public class PTra07_05 {
// 0~4のランダムな整数を作成しています
int random = new Random().nextInt(5);
//String name = int random;
// TODO 配列arrayから変数randomが示す要素を出力してください
System.out.println(random);
}
}