10/16自習

This commit is contained in:
2026-10-16 17:59:31 +09:00
parent 6e9775e57f
commit badb7eb520
62 changed files with 859 additions and 9 deletions

View File

@@ -1,12 +1,17 @@
public class Question04_01 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
for(i == 0; i >= 9; i++) {
System.out.println(i == 5);
break;
int number = 1;
while (number <= 9) {
System.out.println(number);
number = (int)(Math.random() * 10);
if(number == 5) {
break;
}
}
}
}

View File

@@ -1,9 +1,18 @@
public class Question04_02 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int num = 2;
while(num < 1000)//条件式(tureだった場合繰り返し)
{
num *= 2;//文
}
//次の文(falseだった場合表示)
System.out.println(num);
}
}

View File

@@ -0,0 +1,19 @@
import java.util.Random;
public class Question04_03 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int num;
Random rand = new Random();
System.out.println();
do{
num = rand.nextInt(5) + 1;
System.out.println(num);
}while (num != 5);
}
}

View File

@@ -0,0 +1,47 @@
import java.util.Random;
import java.util.Scanner;
public class Question04_04 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner sc = new Scanner(System.in);
//双六の総マス数
int map = 50;
//現在までに進んだマス数
int progress = 0;
//スタート
System.out.println("===== START =====");
while(progress < map) {
System.out.println("Enterキーを押してください。さいころをふります。");
//何かしらの入力
String str = sc.next();
//サイコロを振る
Random random = new Random();
int number = random.nextInt(6) + 1;
//出た目メッセージ
System.out.println(number + "の目が出ました。");
//進んだマス
progress = progress +number;
//残りのマス
int rest = map - progress;
if(rest > 0) {
System.out.println("残りのマスは" + (map - progress) +"マスです");
}
} System.out.println("===== GOAL =====");
}
}

View File

@@ -0,0 +1,23 @@
import java.util.Scanner;
public class Question04_05 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
//勝敗
boolean winFlag = false;
//最初の言葉
System.out.println("じゃんけんを行います。、あなたの出す手を入力してください、0:グー, 1:チョキ, 2:パー");
Scanner sc = new Scanner(System.in);
int select = sc.nextInt();
int playerHand = select;
while(true) {
}
}
}