This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeWork { | |
| public static void main(String[] args) { | |
| int random = new Random().nextInt(3); | |
| int input = new Scanner(System.in).nextInt(); | |
| if (random == input) { | |
| // 同じならあいこ | |
| System.out.println("あいこです。"); | |
| } else { | |
| if (input == 0) { | |
| // もし自分がパーだったら |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeWork { | |
| public static void main(String[] args) { | |
| int[] numbers = new int[100]; | |
| for (int i = 0; i < numbers.length; i++) { | |
| numbers[i] = i; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeWork { | |
| public static void main(String[] args) { | |
| String[] names = new String[] { "長男", "次男", "三男" }; | |
| for (String name : names) { | |
| System.out.println("僕は" + name + "です"); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeWork { | |
| public static void main(String[] args) { | |
| boolean weather = true; | |
| double temperature = 35.5; | |
| if (weather == true && temperature >= 30.0) { | |
| System.out.println("今日は暑いですね"); | |
| } else { | |
| System.out.println("今日は涼しいですね"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Random; | |
| public class HomeWork { | |
| public static void main(String[] args) { | |
| long[] numbers = new long[10]; | |
| for (int i = 0; i < numbers.length; i++) { | |
| numbers[i] = new Random().nextInt(101); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeWork { | |
| public static void main(String[] args) { | |
| int[] menu = new int[3]; | |
| menu[0] = 320; | |
| menu[1] = 320; | |
| menu[2] = 210; | |
| int total = 0; | |
| for (int i : menu) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeWork { | |
| public static void main(String[] args) { | |
| int[] menu = new int[3]; | |
| menu[0] = 320; | |
| menu[1] = 320; | |
| menu[2] = 210; | |
| int total = 0; | |
| for (int i = 0; i < menu.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Mainクラス | |
| import com.example.watanabe.calc.Calc; | |
| public class Main { | |
| public static void main(String[] args) { | |
| int ans = Calc.add(10, 20); | |
| System.out.println("答えは" + ans); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Methods { | |
| public static void main(String[] args) { | |
| hello("しかじろう"); | |
| hello("たなか"); | |
| hello("やまだ"); | |
| int answer = add(3, 4); | |
| System.out.println("戻り値は" + answer); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Calcクラス | |
| package com.example.watanabe.calc; | |
| //計算に特化したクラス | |
| public class Calc { | |
| public static int add(int x, int y) { | |
| return x + y; | |
| } | |
| } |