6 Commits

Author SHA1 Message Date
005b99fcac 本日Q6-1まで 2026-09-11 17:08:26 +09:00
fb3dd4e9a9 Q5終わりました 2026-09-11 16:31:58 +09:00
9126cff440 Q4終わりました 2026-09-11 15:40:48 +09:00
19799db33f Q3終わりました 2026-09-11 14:35:55 +09:00
c29158b399 Q2終わりました 2026-09-11 14:27:11 +09:00
56b5f92977 Q1終わりました 2026-09-11 13:31:22 +09:00
26 changed files with 141 additions and 92 deletions

View File

@@ -6,9 +6,8 @@
*/
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行目のコメントを単一行コメントにしてコンパイルエラーが出ないようにしてください
//ここをコメントアウトする
System.out.println("ここをコメントアウトする");
// TODO 14行目 ~ 16行目を複数行コメントにしてコンパイルエラーが出ないようにしてください
// ここをコメントアウトする
// ここをコメントアウトする
// ここをコメントアウトする
System.out.println("ここをコメントアウトする");
System.out.println("ここをコメントアウトする");
System.out.println("ここをコメントアウトする");
}
}

View File

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

View File

@@ -9,7 +9,9 @@ public class PTra01_04 {
// TODO 数値型の変数 number を 10 で初期化してください。
int number = 10;
// TODO number の値を出力してください
System.out.println(number);
}
}

View File

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

View File

@@ -9,7 +9,9 @@ public class PTra01_06 {
// TODO boolean型の変数 bo を true で初期化してください。
boolean bo = true;
// TODO bo の値を出力してください
System.out.println(bo);
}
}

View File

@@ -9,7 +9,9 @@ public class PTra01_07 {
// TODO long型の変数 lo を 1000000000000 で初期化してください。
long lo = 1000000000000L;
// TODO lo の値を出力してください
System.out.println(lo);
}
}

View File

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

View File

@@ -8,10 +8,36 @@ public class PTra01_09 {
public static void main(String[] args) {
// TODO 基本型8種類の変数を宣言します(変数名は自分できめてOKです)
int in;
String str;
int number;
char[] ch = {'A'};
boolean bo;
long lo;
float fl;
byte by;
short sh;
// TODO 宣言した変数に、値を代入してください(代入する値はなんでもOKです)
in = (123);
str = "こんにちは";
number = 8;
bo = true;
lo = 100000000L;
fl = 1.14f;
by = 127;
sh = 32767;
// TODO それぞれの変数の中身を出力してください
System.out.println(in);
System.out.println(str);
System.out.println(number);
System.out.println(ch);
System.out.println(bo);
System.out.println(lo);
System.out.println(fl);
System.out.println(by);
System.out.println(sh);
}
}

View File

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

View File

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

View File

@@ -11,6 +11,7 @@ public class PTra02_03 {
// TODO numに5を足した値をnumに代入してください
num = num + 5;
// numの値を出力します(編集しないでください)。
// ※ 15と出力されれば正解です。
System.out.println(num);

View File

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

View File

@@ -10,16 +10,16 @@ public class PTra02_08 {
// 所持金
int money = 1000;
// 商品価格(税抜)
double price = 580;
int price = 580;
// 消費税率
double taxRate = 0.08;
// TODO 買い物した際の残金計算をします。
// TODO 所持金から価格を引いた値を、買い物後の所持金として再代入してください。
// ※消費税を考慮してください。税込み商品価格の端数は切り捨てとします。
price = price *( 1 + taxRate);
int pay = (int) price;
money = money - pay;
int totalPrice = (int)(price * (1 + taxRate));
money = money - totalPrice;
// 残金の表示部分です。編集しないでください
System.out.println("残金は" + money + "円です。");
}

View File

@@ -12,8 +12,9 @@ public class PTra03_02 {
// ※ 合格です と表示されれば正解
if (num >= 65) {
System.out.println("合格です");
}else {
System.out.println("不合格です");
} else {
System.out.println("不合格です");
}
}
}

View File

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

View File

@@ -20,14 +20,12 @@ public class PTra03_04 {
*
* ※ 変数numの値が 0より小さい または 100より大きい場合は「不正な値が入力されました」と出力してください。
*/
if (num >= 75) {
if(num >= 75) {
System.out.println("雨が降る確率が高いです");
}
else if (num >= 30) {
}else if(num >= 30) {
System.out.println("雨が降るかもしれないです");
}
else if (num < 30) {
System.out.println("雨は降らないでしょう");
}else {
System.out.println("雨はまず降らないでしょう");
}
}
}

View File

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

View File

@@ -16,9 +16,11 @@ public class PTra04_02 {
* ※ 繰り返しにはwhile文を用いてください
*/
while (num <= 1000) {
System.out.println(num);
num = num * 2;
System.out.println(num);
}
System.out.println(num);
}
}

View File

@@ -1,4 +1,3 @@
/*
* PTra04_03.java
* 作成 Rhizome
@@ -17,14 +16,18 @@ public class PTra04_03 {
// 以下のwhile文は0~9のランダムな値をコンソールに出力する処理を無限に繰り返します。
// TODO 5が出力されたら繰り返しを止めるようにしてください。
// ※ while文の条件は変更せずにbreak文を使ってください。
while (true) {
while(true) {
// 0~9のランダムな値を生成
randomNumber = random.nextInt(10);
if (randomNumber == 5) {
System.out.println("5が出たので終了します。");
break;
}
// 生成した値をコンソールに出力
System.out.println(randomNumber);
if (randomNumber == 5) {
break;
}
}
}
}

View File

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

View File

@@ -36,9 +36,12 @@ public class PTra04_05 {
if (playerHand == 0) {
System.out.println("あなたはグーを出しました");
} else if (playerHand == 1) {
System.out.println("あなたはチョキを出しました");
System.out.println("あなたはチョキをだしました");
} else if (playerHand == 2) {
System.out.println("あなたはパーを出しました");
} else {
System.out.println("正しい数字を記入してください");
continue;
}
// 対戦相手の手をランダムに選択する。
@@ -47,32 +50,20 @@ public class PTra04_05 {
if (npcHand == 0) {
System.out.println("相手はグーを出しました");
} else if (npcHand == 1) {
System.out.println("相手はチョキを出しました");
} else if (npcHand == 2) {
System.out.println("相手はチョキをだしました");
} else {
System.out.println("相手はパーを出しました");
}
// TODO じゃんけんの結果を出力し、プレイヤーが勝った場合はプログラムが終了するようにしてください。
if (playerHand == 0 && npcHand == 1) {
if (playerHand == npcHand) {
System.out.println("あいこです。もう一度!");
} else if ((playerHand == 0 && npcHand == 2) || (playerHand == 1 && npcHand == 0)
|| (playerHand == 2 && npcHand == 1)) {
System.out.println("あなたの負けです。もう一度!");
} else {
System.out.println("あなたの勝ちです!");
return;
} else if (playerHand == 0 && npcHand == 0) {
System.out.println("あいこです。もう一度チャレンジ!");
} else if (playerHand == 0 && npcHand == 2) {
System.out.println("負けちゃいました…。もう一度チャレンジ!");
} else if (playerHand == 1 && npcHand == 1) {
System.out.println("あいこです。もう一度チャレンジ!");
} else if (playerHand == 1 && npcHand == 0) {
System.out.println("負けちゃいました…。もう一度チャレンジ!");
} else if (playerHand == 1 && npcHand == 2) {
System.out.println("あなたの勝ちです!");
return;
} else if (playerHand == 2 && npcHand == 0) {
System.out.println("あなたの勝ちです!");
return;
} else if (playerHand == 2 && npcHand == 1) {
System.out.println("負けちゃいました…。もう一度チャレンジ!");
} else if (playerHand == 2 && npcHand == 2) {
System.out.println("あいこです。もう一度チャレンジ!");
break;
}
// 次のじゃんけんの前に改行しておく
System.out.println();

View File

@@ -26,21 +26,28 @@ public class PTra05_01 {
case 0:
System.out.println("あなたの運勢は「大吉」です");
break;
case 1:
System.out.println("あなたの運勢は「吉」です");
break;
case 2:
System.out.println("あなたの運勢は「中吉」です");
break;
case 3:
System.out.println("あなたの運勢は「小吉」です");
break;
case 4:
System.out.println("あなたの運勢は「末吉」です");
break;
case 5:
System.out.println("あなたの運勢は「凶」です");
break;
}
}
}

View File

@@ -47,6 +47,7 @@ public class PTra05_02 {
break;
default:
System.out.println("計算に失敗しました");
}
}

View File

@@ -44,22 +44,22 @@ public class PTra05_03 {
// ※ H か L 以外の文字が入力された場合は、「不正な値が入力されました」と出力してください。
switch (judgement) {
case "H":
if (dealerCard <= myCard) {
System.out.println("あなたの勝ちです");
} else {
System.out.println("あなたの負けです");
}
if(myCard >= dealerCard) {
System.out.println("あなたの勝ちです");
}else {
System.out.println("あなたの負けです");
}
break;
case "L":
if (dealerCard >= myCard) {
System.out.println("あなたの勝ちです");
} else {
if(myCard <= dealerCard) {
System.out.println("あなたの価値です");
}else {
System.out.println("あなたの負けです");
}
break;
default:
System.out.println("不正な数値が入力されました");
}
default:
System.out.println("不正な値が入力されました");
}
}
}

View File

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