This file contains 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
int x; | |
int y; | |
int z; | |
x = 63; | |
y = 18; | |
z = 20; | |
System.out.println("xの値は" + x + "です。"); | |
System.out.println("yの値は" + y + "です。"); |
This file contains 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.Scanner; | |
public class En2_3 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("整数値:"); | |
int seisu = stdIn.nextInt(); |
This file contains 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文を設定。 | |
import java.util.Scanner; | |
public class En2_4 { | |
public static void main(String[] args) { | |
// スキャナー変数を宣言。 | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("整数値:"); |
This file contains 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.Scanner; | |
public class En2_5 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("xの値:"); | |
// 実数値で読み込み | |
double x = stdIn.nextDouble(); |
This file contains 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.Scanner; | |
public class En2_6 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.println("三角形の面積を求めます。"); | |
// 実数を読み込み | |
System.out.print("底辺:"); |
This file contains 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 En2_7 { | |
public static void main(String[] args) { | |
// 乱数読み込み | |
Random rand = new Random(); | |
// 0~8までの乱数作成し、それに+1する。 | |
int ransu1 = rand.nextInt(9) + 1; |
This file contains 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; | |
import java.util.Scanner; | |
public class En2_8 { | |
public static void main(String[] args) { | |
Random rand = new Random(); | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("整数値:"); | |
int seisu = stdIn.nextInt(); |
This file contains 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 En2_9 { | |
public static void main(String[] args) { | |
Random rand = new Random(); | |
// (1)実数値でのランダム生成 | |
double jisu = rand.nextDouble(); | |
// (2)整数値で0~9をのランダム生成 | |
int seisu = rand.nextInt(10); |
This file contains 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.Scanner; | |
public class En2_10 { | |
public static void main(String[] args){ | |
Scanner stdIn = new Scanner(System.in); | |
//キーボドからString型で読み込む。 | |
System.out.print("性:"); | |
String sei = stdIn.next(); |
This file contains 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.Scanner; | |
public class En3_1 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("絶対値:"); | |
int zettai = stdIn.nextInt(); |
OlderNewer