2025_06_Log🗓️

← Back to Java Study Log

2025/06/14(Sat)

Gitをインストールして、Githubにリポジトリを作った。
このブログのHTMLデータをプッシュして、iPadでも見られるようにしたよ。

2025/06/13(Fri)

勉強記録のページを増設。難しい。

2025/06/12(Thu)

Copilotに練習問題を出してもらったよ

↓定番のHelloWorld

public class SayHello {
public static void main(String[]args) {	
	System.out.println("Hello World!");
}

}

★実行結果:

Hello World!

↓簡単な計算機

public class Calculator {
	public static void main(String[]args) {
		
		int a = 20;
		int b = 5;
		
		System.out.println("足し算の答えは"+(a+b)+"です!");
		System.out.println("引き算の答えは"+ (a-b) +"です!");
		System.out.println("掛け算の答えは"+a*b+"です!");
		System.out.println("割り算の答えは"+a/b+"です!");
		System.out.println("割り算の余りは"+a%b+"です!");

	}

}

★実行結果:

足し算の答えは25です!
引き算の答えは15です!
掛け算の答えは100です!
割り算の答えは4です!
割り算の余りは0です!

↓配列の練習

public class Hairetsu {
  public static void main(String[] args) {
    int[] num = {1, 2, 3, ..., 20};
    
    for (int i = 0; i < num.length; i++) {
      if (num[i] % 2 != 0) {
        System.out.println(num[i]);
      }
    }
  }
}

★実行結果:

1
3
5
7
9
11
13
15
17
19

↓入力された点数を採点し、評価を返す

import java.util.Scanner;

public class TestScore {
	public static void main(String[]args) {
		
		Scanner sc = new Scanner(System.in);
		
		
		System.out.println("Please enter your score!");

		int score = sc.nextInt();
		
		System.out.println("Your score is "+score);
		
		if(score==100) {
			System.out.println("Perfect!!");
		}else if(score>=80) {
			System.out.println("Great!");
		}else if(score >=50) {
			System.out.println("Good!");
		}else{
			System.out.println("Ganbare!");
		}
		
		sc.close();
			
	}

}

★実行結果:

Please enter your score!
Your score is 89
Great!

↓ランダムな数字を定数で定義し、当てるミニゲーム

import java.util.Scanner;

public class Random {
	public static void main(String[]args) {
		
		final int NUM = (int) (Math.random()*10);
		System.out.println("Guess the number between 0 and 9!");
		Scanner sc = new Scanner(System.in);
		int number;
		
		do {
			number = sc.nextInt();
			System.out.println("The number you entered is "+number);

			if(number!=NUM) {
				System.out.println("Wrong anser!!Try again!");
			}else{
				System.out.println("Congratulation!! The number was "+ NUM+" !");
			}
			
		}while (number != NUM);
		
		sc.close();
	}

}

★実行結果:

Guess the number between 0 and 9!"
The number you entered is 〇
Wrong anser!!Try again!
The number you entered is *
Congratulation!! The number was * !

だんだん書けるように成長してる、気がする。。

2025/06/08(Sun)

練習がてら、HTMLとCSSでブログページを作成中!