Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a1e817855 | |||
| 85a626ef91 | |||
| 81d17fd20a |
6
Question01-StartProgram/.classpath
Normal file
6
Question01-StartProgram/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
Question01-StartProgram/.gitignore
vendored
Normal file
1
Question01-StartProgram/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
Question01-StartProgram/.project
Normal file
17
Question01-StartProgram/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question01-StartProgram</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
public class PTra01_01 {
|
||||
public static void main(String[] args) {
|
||||
System.out.print("Hello World");
|
||||
//TODO Hello,world と出力してください
|
||||
|
||||
//TODO Hello,world と出力してください
|
||||
System.out.println("Hello,world");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
*/
|
||||
public class PTra01_02 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// TODO 11行目のコメントを単一行コメントにしてコンパイルエラーが出ないようにしてください
|
||||
//ここをコメントアウトする
|
||||
|
||||
// TODO 14行目 ~ 16行目を複数行コメントにしてコンパイルエラーが出ないようにしてください
|
||||
/*ここをコメントアウトする
|
||||
ここをコメントアウトする
|
||||
ここをコメントアウトする*/
|
||||
// ここをコメントアウトする
|
||||
// ここをコメントアウトする
|
||||
// ここをコメントアウトする
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
*/
|
||||
public class PTra01_03 {
|
||||
public static void main(String[] args) {
|
||||
String str;
|
||||
|
||||
// TODO 文字列型の変数 str を宣言してください。
|
||||
str = "こんにちは";
|
||||
String str = "こんにちは";
|
||||
// TODO str に こんにちは を代入してください
|
||||
System.out.println(str);
|
||||
// TODO str の値を出力してください
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
public class PTra01_04 {
|
||||
public static void main(String[] args) {
|
||||
int num = 10;
|
||||
// TODO 数値型の変数 number を 10 で初期化してください。
|
||||
System.out.println(num);
|
||||
// TODO number の値を出力してください
|
||||
|
||||
// TODO 数値型の変数 number を 10 で初期化してください。
|
||||
int number = 10;
|
||||
// TODO number の値を出力してください
|
||||
System.out.println(number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
public class PTra01_05 {
|
||||
public static void main(String[] args) {
|
||||
char ch = 'A';
|
||||
// TODO char型の変数 ch を A で初期化してください。
|
||||
System.out.println(ch);
|
||||
// TODO ch の値を出力してください
|
||||
|
||||
// TODO char型の変数 ch を A で初期化してください。
|
||||
char ch = 'A';
|
||||
// TODO ch の値を出力してください
|
||||
System.out.println(ch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
public class PTra01_06 {
|
||||
public static void main(String[] args) {
|
||||
boolean bo = true;
|
||||
// TODO boolean型の変数 bo を true で初期化してください。
|
||||
System.out.println(bo);
|
||||
// TODO bo の値を出力してください
|
||||
|
||||
// TODO boolean型の変数 bo を true で初期化してください。
|
||||
boolean bo = true;
|
||||
// TODO bo の値を出力してください
|
||||
System.out.println(bo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
public class PTra01_07 {
|
||||
public static void main(String[] args) {
|
||||
long lo = 1000000000000L;
|
||||
// TODO long型の変数 lo を 1000000000000 で初期化してください。
|
||||
System.out.println(lo);
|
||||
// TODO lo の値を出力してください
|
||||
|
||||
// TODO long型の変数 lo を 1000000000000 で初期化してください。
|
||||
long lo = 1000000000000L;
|
||||
// TODO lo の値を出力してください
|
||||
System.out.println(lo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
public class PTra01_08 {
|
||||
public static void main(String[] args) {
|
||||
float fl = 3.14f;
|
||||
// TODO float型の変数 fl を 3.14 で初期化してください。
|
||||
System.out.println(fl);
|
||||
// TODO fl の値を出力してください
|
||||
|
||||
// TODO float型の変数 fl を 3.14 で初期化してください。
|
||||
float fl = 3.14f;
|
||||
// TODO fl の値を出力してください
|
||||
System.out.println(fl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,33 +6,30 @@
|
||||
*/
|
||||
public class PTra01_09 {
|
||||
public static void main(String[] args) {
|
||||
byte smal ;
|
||||
short mediam;
|
||||
int count;
|
||||
long big;
|
||||
float lot;
|
||||
double price;
|
||||
char S;
|
||||
boolean a;
|
||||
|
||||
// TODO 基本型8種類の変数を宣言します(変数名は自分できめてOKです)
|
||||
smal = 127;
|
||||
mediam = 32000;
|
||||
count =2000000;
|
||||
big =9000000000L;
|
||||
lot = 3;
|
||||
price =1980.5;
|
||||
S='咲';
|
||||
a = true;
|
||||
String st = "Hello";
|
||||
int in = 2;
|
||||
char ch = 'a';
|
||||
boolean boo = true;
|
||||
double dou = 1.0e308;
|
||||
long lo = 2222222222222L;
|
||||
float fo = 3.12f;
|
||||
byte byt = 124;
|
||||
short sh = 42;
|
||||
|
||||
// TODO 宣言した変数に、値を代入してください(代入する値はなんでもOKです)
|
||||
System.out.println(smal);
|
||||
System.out.println(mediam);
|
||||
System.out.println(count);
|
||||
System.out.println(big);
|
||||
System.out.println(lot);
|
||||
System.out.println(price);
|
||||
System.out.println(S);
|
||||
System.out.println(a);
|
||||
|
||||
// TODO それぞれの変数の中身を出力してください
|
||||
System.out.println(st);
|
||||
System.out.println(in);
|
||||
System.out.println(ch);
|
||||
System.out.println(boo);
|
||||
System.out.println(dou);
|
||||
System.out.println(lo);
|
||||
System.out.println(fo);
|
||||
System.out.println(byt);
|
||||
System.out.println(sh);;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
6
Question02-Expressions/.classpath
Normal file
6
Question02-Expressions/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
Question02-Expressions/.gitignore
vendored
Normal file
1
Question02-Expressions/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
Question02-Expressions/.project
Normal file
17
Question02-Expressions/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question02-Expressions</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -7,22 +7,21 @@
|
||||
public class PTra02_01 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int sum;
|
||||
int diff;
|
||||
int mulch;
|
||||
int div;
|
||||
int rem;
|
||||
int sum = 6+2;
|
||||
int diff = 6-2;
|
||||
int mulch = 6*2;
|
||||
int div = 6/2;
|
||||
int rem = 17%5 ;
|
||||
|
||||
// TODO 6+2を計算して結果を変数sumに代入してください
|
||||
sum = 6 + 2;
|
||||
|
||||
// TODO 6-2を計算して結果を変数diffに代入してください
|
||||
diff = 6 - 2;
|
||||
|
||||
// TODO 6×2を計算して結果を変数mulchに代入してください
|
||||
mulch = 6 * 2;
|
||||
|
||||
// TODO 6÷2を計算して結果を変数divに代入してください
|
||||
div = 6 / 2;
|
||||
|
||||
// TODO 17÷5の余りを計算して変数remに代入してください
|
||||
rem = 17 % 5;
|
||||
|
||||
// 各変数の表示(編集しないでください)
|
||||
// ※ 8, 4, 12, 3, 2の順で表示されれば正解です
|
||||
|
||||
@@ -9,11 +9,11 @@ public class PTra02_02 {
|
||||
public static void main(String[] args) {
|
||||
String firstName = "太郎";
|
||||
String lastName = "山田";
|
||||
System.out.println(lastName + firstName);
|
||||
|
||||
// TODO 苗字と名前をつなげて山田太郎と出力してください。
|
||||
// ※ System.out.printlnを使うのは1回だけです。
|
||||
|
||||
String Name = lastName.concat(firstName);
|
||||
System.out.println(Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ public class PTra02_03 {
|
||||
int num = 10;
|
||||
|
||||
// TODO numに5を足した値をnumに代入してください
|
||||
|
||||
num = 10 + 5;
|
||||
// numの値を出力します(編集しないでください)。
|
||||
// ※ 15と出力されれば正解です。
|
||||
System.out.println(num + 5);
|
||||
System.out.println(num);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ public class PTra02_06 {
|
||||
public static void main(String[] args) {
|
||||
// 以下のプログラムを実行すると割り算の結果の小数点以下が切り捨てられてしまいます。
|
||||
// TODO 切り捨てられないように修正してください。
|
||||
double a = 9;
|
||||
int b = 2;
|
||||
System.out.println(a/b);
|
||||
double A = 9;
|
||||
int B = 2;
|
||||
System.out.println(A/B);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,18 @@
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
public class PTra02_07 {
|
||||
public static void main(String[] args) {
|
||||
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
|
||||
// ※数値リテラル部分は編集しないでください
|
||||
double s = 1.0;
|
||||
int num = (int) s;
|
||||
|
||||
double num1 = 1.0;
|
||||
int num = (int)num1;
|
||||
|
||||
// ※ 以下は編集しないでください。1と出力されていれば正解です
|
||||
System.out.println(num);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ public class PTra02_08 {
|
||||
// 消費税率
|
||||
double taxRate = 0.08;
|
||||
|
||||
int tax = (int)(price + (price * taxRate)) ;
|
||||
|
||||
money = money - tax;
|
||||
// TODO 買い物した際の残金計算をします。
|
||||
// TODO 所持金から価格を引いた値を、買い物後の所持金として再代入してください。
|
||||
// ※消費税を考慮してください。税込み商品価格の端数は切り捨てとします。
|
||||
|
||||
double price2 = price*1.08;
|
||||
int price3 = (int)price2;
|
||||
money = (money - price3);
|
||||
|
||||
// 残金の表示部分です。編集しないでください
|
||||
System.out.println("残金は" + money + "円です。");
|
||||
|
||||
6
Question03-if/.classpath
Normal file
6
Question03-if/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
Question03-if/.gitignore
vendored
Normal file
1
Question03-if/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
Question03-if/.project
Normal file
17
Question03-if/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question03-if</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -8,9 +8,9 @@ public class PTra03_01 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// TODO int型の変数numを宣言し、100で初期化してください
|
||||
|
||||
int num = 100;
|
||||
// TODO「変数numが100である」という条件式を追加してください
|
||||
if () {
|
||||
if (num == 100) {
|
||||
System.out.println("条件に合致しました");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
public class PTra03_02 {
|
||||
public static void main(String[] args) {
|
||||
// TODO int型の変数numを宣言し、65で初期化してください
|
||||
|
||||
int num = 65;
|
||||
// TODO 変数numの値が65以上の場合は「合格です」と出力し、それ以外であれば「不合格です」を出力してください
|
||||
// ※ 合格です と表示されれば正解
|
||||
|
||||
if (num >= 65) {
|
||||
System.out.println("合格です");
|
||||
}else {
|
||||
System.out.println("不合格です");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,10 @@ public class PTra03_03 {
|
||||
int num = 10;
|
||||
|
||||
// TODO numが 2で割り切れる かつ 5で割り切れるという条件式を記述してください
|
||||
if () {
|
||||
if ( num%2 == 0 && num%5 == 0 ){
|
||||
{
|
||||
System.out.println(num + "は2でも5でも割り切れます。");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
public class PTra03_04 {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("降水確率を入力してください。(数字のみ)");
|
||||
@@ -20,5 +21,16 @@ public class PTra03_04 {
|
||||
*
|
||||
* ※ 変数numの値が 0より小さい または 100より大きい場合は「不正な値が入力されました」と出力してください。
|
||||
*/
|
||||
if (num >= 75 && num <= 100) {
|
||||
System.out.println("雨が降る確率が高いです");
|
||||
}else if (num >= 30 && num < 75) {
|
||||
System.out.println("雨が降るかもしれないです");
|
||||
}
|
||||
else if (num < 30){
|
||||
System.out.println("雨はまず降らないでしょう");
|
||||
}
|
||||
else if (num < 0 || num >100 ) {
|
||||
System.out.println("不正な値が入力されました");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user