完了済

This commit is contained in:
2026-10-09 09:49:41 +09:00
parent f9779651c7
commit 62be6a9ae8
9 changed files with 135 additions and 0 deletions

1
Question02-Expressions/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build/

View File

@@ -0,0 +1,23 @@
public class Question2_1 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int sum, diff, mulch, div, rem;
sum = 6 + 2;
diff = 6 - 2;
mulch = 6 * 2;
div = 6 / 2;
rem = 17 % 5;
System.out.println("変数sum:" + sum);
System.out.println("変数diff:" + diff);
System.out.println("変数mulch:" + mulch);
System.out.println("変数div:" + div);
System.out.println("変数rem:" + rem);
}
}

View File

@@ -0,0 +1,14 @@
public class Question2_2 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String lastName = "太郎";
String firstName = "山田";
System.out.println(firstName+lastName);
}
}

View File

@@ -0,0 +1,15 @@
public class Question2_3 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int num = 10;
num = num + 5;
System.out.println(num);
}
}

View File

@@ -0,0 +1,18 @@
public class Question2_4 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
// error
// int sum;
// sum = 10 + 3.14;
double sum;
sum = 10 + 3.14;
System.out.println(sum);
}
}

View File

@@ -0,0 +1,15 @@
public class Question2_5 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int age = 20;
int diff = 5;
System.out.println("山田さんは"+age+"歳です。");
System.out.println(diff+"年後には"+(age+diff)+"歳になります。");
}
}

View File

@@ -0,0 +1,14 @@
public class Question2_6 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int numerator = 9;
int denominator = 2;
System.out.println( (float)numerator/(float)denominator );
}
}

View File

@@ -0,0 +1,18 @@
public class Question2_7 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int num;
// error
// num = 1.0;
num = (int)1.0;
System.out.println(num);
}
}

View File

@@ -0,0 +1,17 @@
public class Question2_8 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int money = 1000;
int price = 580;
float taxRate = 0.08F;
money = money - (int)( price*(1.0+taxRate) );
System.out.println("残金は"+money+"円です。");
}
}