Question2です
This commit is contained in:
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,11 +7,11 @@
|
||||
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に代入してください
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ public class PTra02_02 {
|
||||
|
||||
// TODO 苗字と名前をつなげて山田太郎と出力してください。
|
||||
// ※ System.out.printlnを使うのは1回だけです。
|
||||
|
||||
String Name = lastName.concat(firstName);
|
||||
System.out.println(Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class PTra02_03 {
|
||||
int num = 10;
|
||||
|
||||
// TODO numに5を足した値をnumに代入してください
|
||||
|
||||
num = 10 + 5;
|
||||
// numの値を出力します(編集しないでください)。
|
||||
// ※ 15と出力されれば正解です。
|
||||
System.out.println(num);
|
||||
|
||||
@@ -9,7 +9,7 @@ public class PTra02_04 {
|
||||
public static void main(String[] args) {
|
||||
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
|
||||
// ※数値リテラル部分は編集しないでください
|
||||
int sum = 10 + 3.14;
|
||||
double sum = 10 + 3.14;
|
||||
|
||||
// ※以下は編集しないでください。13.14と出力されていれば正解です
|
||||
System.out.println(sum);
|
||||
|
||||
@@ -19,7 +19,7 @@ public class PTra02_05 {
|
||||
int diff = 5;
|
||||
|
||||
System.out.println("山田さんは" + age + "歳です。");
|
||||
System.out.println(diff + "年後には" + age + diff + "歳になります。");
|
||||
System.out.println(diff + "年後には" + (age + diff) + "歳になります。");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ public class PTra02_06 {
|
||||
public static void main(String[] args) {
|
||||
// 以下のプログラムを実行すると割り算の結果の小数点以下が切り捨てられてしまいます。
|
||||
// TODO 切り捨てられないように修正してください。
|
||||
System.out.println(9/2);
|
||||
double A = 9;
|
||||
int B = 2;
|
||||
System.out.println(A/B);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
public class PTra02_07 {
|
||||
public static void main(String[] args) {
|
||||
// TODO 以下のソースコードからコンパイルエラーを取り除いてください
|
||||
// ※数値リテラル部分は編集しないでください
|
||||
int num = 1.0;
|
||||
|
||||
|
||||
double num1 = 1.0;
|
||||
int num = (int)num1;
|
||||
|
||||
// ※ 以下は編集しないでください。1と出力されていれば正解です
|
||||
System.out.println(num);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ public class PTra02_08 {
|
||||
// TODO 買い物した際の残金計算をします。
|
||||
// TODO 所持金から価格を引いた値を、買い物後の所持金として再代入してください。
|
||||
// ※消費税を考慮してください。税込み商品価格の端数は切り捨てとします。
|
||||
|
||||
|
||||
double price2 = price*1.08;
|
||||
int price3 = (int)price2;
|
||||
money = (money - price3);
|
||||
|
||||
// 残金の表示部分です。編集しないでください
|
||||
System.out.println("残金は" + money + "円です。");
|
||||
|
||||
Reference in New Issue
Block a user