Compare commits
4 Commits
1227de3967
...
s-ohashi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2418206e26 | ||
|
|
1efcc4228c | ||
|
|
2ce170f405 | ||
|
|
48ee98536a |
29
.classpath
29
.classpath
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="Question01-StartProgram/src"/>
|
||||
<classpathentry kind="src" path="Question02-Expressions/src"/>
|
||||
<classpathentry kind="src" path="Question03-if/src"/>
|
||||
<classpathentry kind="src" path="Question04-while/src"/>
|
||||
<classpathentry kind="src" path="Question05-switch/src"/>
|
||||
<classpathentry kind="src" path="Question06-for/src"/>
|
||||
<classpathentry kind="src" path="Question07-Array/src"/>
|
||||
<classpathentry kind="src" path="Question08-Method/src"/>
|
||||
<classpathentry kind="src" path="Question09-Package/src"/>
|
||||
<classpathentry kind="src" path="Question10-InstanceAndClass/src"/>
|
||||
<classpathentry kind="src" path="Question11-ConstructorAndStatic/src"/>
|
||||
<classpathentry kind="src" path="Question12-Encapsulation/src"/>
|
||||
<classpathentry kind="src" path="Question13-Extends/src"/>
|
||||
<classpathentry kind="src" path="Question14-Interface/src"/>
|
||||
<classpathentry kind="src" path="Question15-Polymorphism/src"/>
|
||||
<classpathentry kind="src" path="Question16-JavaStandardClass/src"/>
|
||||
<classpathentry kind="src" path="Question17-Exception/src"/>
|
||||
<classpathentry kind="src" path="Question18-StringOperation/src"/>
|
||||
<classpathentry kind="src" path="Question19-Collection/src"/>
|
||||
<classpathentry kind="src" path="Question20-InstanceBasicOperation/src"/>
|
||||
<classpathentry kind="src" path="Question21-DifferentTypesClass/src"/>
|
||||
<classpathentry kind="src" path="Question22-FunctionAndLambda/src"/>
|
||||
<classpathentry kind="src" path="Question23-NonStandardLibrary/src"/>
|
||||
<classpathentry kind="src" path="Question24-VariousFileFormats/src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,4 +24,3 @@
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
/bin/
|
||||
|
||||
17
.project
17
.project
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>java-question</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,9 +6,8 @@
|
||||
*/
|
||||
public class PTra01_01 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
//TODO Hello,world と出力してください
|
||||
System.out.println("Hello,world");
|
||||
System.out.print("Hello World");
|
||||
//TODO Hello,world と出力してください
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
public class PTra01_02 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// TODO 11行目のコメントを単一行コメントにしてコンパイルエラーが出ないようにしてください
|
||||
//ここをコメントアウトする
|
||||
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
*/
|
||||
public class PTra01_03 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
String str;
|
||||
// TODO 文字列型の変数 str を宣言してください。
|
||||
String str;
|
||||
|
||||
str = "こんにちは";
|
||||
// TODO str に こんにちは を代入してください
|
||||
str = "こんにちは";
|
||||
|
||||
System.out.println(str);
|
||||
// TODO str の値を出力してください
|
||||
System.out.println(str);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
public class PTra01_04 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
int num = 10;
|
||||
// TODO 数値型の変数 number を 10 で初期化してください。
|
||||
int number = 10;
|
||||
|
||||
System.out.println(num);
|
||||
// TODO number の値を出力してください
|
||||
System.out.println(number);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
public class PTra01_05 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
char ch = 'A';
|
||||
// TODO char型の変数 ch を A で初期化してください。
|
||||
char ch = 'A';
|
||||
|
||||
System.out.println(ch);
|
||||
// TODO ch の値を出力してください
|
||||
System.out.println(ch);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
public class PTra01_06 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
boolean bo = true;
|
||||
// TODO boolean型の変数 bo を true で初期化してください。
|
||||
boolean bo = true;
|
||||
|
||||
System.out.println(bo);
|
||||
// TODO bo の値を出力してください
|
||||
System.out.println(bo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
public class PTra01_07 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
long lo = 1000000000000L;
|
||||
// TODO long型の変数 lo を 1000000000000 で初期化してください。
|
||||
long lo = 1000000000000L;
|
||||
|
||||
System.out.println(lo);
|
||||
// TODO lo の値を出力してください
|
||||
System.out.println(lo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
*/
|
||||
public class PTra01_08 {
|
||||
public static void main(String[] args) {
|
||||
|
||||
float fl = 3.14f;
|
||||
// TODO float型の変数 fl を 3.14 で初期化してください。
|
||||
float fl = 3.14F;
|
||||
|
||||
System.out.println(fl);
|
||||
// TODO fl の値を出力してください
|
||||
System.out.println(fl);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,40 +6,33 @@
|
||||
*/
|
||||
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です)
|
||||
|
||||
byte bNum;
|
||||
short sNum;
|
||||
int iNum;
|
||||
long lNum;
|
||||
float fMin;
|
||||
double dMin;
|
||||
char ch1;
|
||||
boolean boo;
|
||||
|
||||
|
||||
|
||||
|
||||
smal = 127;
|
||||
mediam = 32000;
|
||||
count =2000000;
|
||||
big =9000000000L;
|
||||
lot = 3;
|
||||
price =1980.5;
|
||||
S='咲';
|
||||
a = true;
|
||||
// TODO 宣言した変数に、値を代入してください(代入する値はなんでもOKです)
|
||||
bNum = 127;
|
||||
sNum = 30000;
|
||||
iNum = 10000;
|
||||
lNum = 50000L;
|
||||
fMin = 0.01F;
|
||||
dMin = 0.001;
|
||||
ch1 = 'N';
|
||||
boo = true;
|
||||
|
||||
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(bNum);
|
||||
System.out.println(sNum);
|
||||
System.out.println(iNum);
|
||||
System.out.println(lNum);
|
||||
System.out.println(fMin);
|
||||
System.out.println(dMin);
|
||||
System.out.println(ch1);
|
||||
System.out.println(boo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,15 @@ public class PTra02_01 {
|
||||
int rem;
|
||||
|
||||
// TODO 6+2を計算して結果を変数sumに代入してください
|
||||
sum = 6 + 2;
|
||||
|
||||
sum = 6 + 2;
|
||||
// TODO 6-2を計算して結果を変数diffに代入してください
|
||||
diff = 6 - 2;
|
||||
|
||||
diff = 6 - 2;
|
||||
// TODO 6×2を計算して結果を変数mulchに代入してください
|
||||
mulch = 6 * 2;
|
||||
|
||||
mulch = 6 * 2;
|
||||
// TODO 6÷2を計算して結果を変数divに代入してください
|
||||
div = 6 / 2;
|
||||
|
||||
div = 6 / 2;
|
||||
// TODO 17÷5の余りを計算して変数remに代入してください
|
||||
rem = 17 % 5;
|
||||
rem = 17 % 5;
|
||||
|
||||
// 各変数の表示(編集しないでください)
|
||||
// ※ 8, 4, 12, 3, 2の順で表示されれば正解です
|
||||
|
||||
@@ -9,10 +9,10 @@ public class PTra02_02 {
|
||||
public static void main(String[] args) {
|
||||
String firstName = "太郎";
|
||||
String lastName = "山田";
|
||||
System.out.println(lastName + firstName);
|
||||
|
||||
// TODO 苗字と名前をつなげて山田太郎と出力してください。
|
||||
// ※ System.out.printlnを使うのは1回だけです。
|
||||
System.out.println(lastName + firstName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,10 @@ public class PTra02_03 {
|
||||
int num = 10;
|
||||
|
||||
// TODO numに5を足した値をnumに代入してください
|
||||
num = num + 5;
|
||||
|
||||
// numの値を出力します(編集しないでください)。
|
||||
// ※ 15と出力されれば正解です。
|
||||
System.out.println(num);
|
||||
System.out.println(num + 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ public class PTra02_06 {
|
||||
public static void main(String[] args) {
|
||||
// 以下のプログラムを実行すると割り算の結果の小数点以下が切り捨てられてしまいます。
|
||||
// TODO 切り捨てられないように修正してください。
|
||||
|
||||
System.out.println((double)9/2);
|
||||
double a = 9;
|
||||
int b = 2;
|
||||
System.out.println(a/b);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ public class PTra02_07 {
|
||||
public static void main(String[] args) {
|
||||
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
|
||||
// ※数値リテラル部分は編集しないでください
|
||||
int num = (int)1.0;
|
||||
double s = 1.0;
|
||||
int num = (int) s;
|
||||
|
||||
// ※ 以下は編集しないでください。1と出力されていれば正解です
|
||||
System.out.println(num);
|
||||
|
||||
@@ -14,10 +14,13 @@ public class PTra02_08 {
|
||||
// 消費税率
|
||||
double taxRate = 0.08;
|
||||
|
||||
int tax = (int)(price + (price * taxRate)) ;
|
||||
|
||||
money = money - tax;
|
||||
// TODO 買い物した際の残金計算をします。
|
||||
// TODO 所持金から価格を引いた値を、買い物後の所持金として再代入してください。
|
||||
// ※消費税を考慮してください。税込み商品価格の端数は切り捨てとします。
|
||||
money = money - (price + (int)(price * taxRate));
|
||||
|
||||
|
||||
// 残金の表示部分です。編集しないでください
|
||||
System.out.println("残金は" + money + "円です。");
|
||||
|
||||
Reference in New Issue
Block a user