Question3です

This commit is contained in:
2026-09-11 16:55:42 +09:00
parent 85a626ef91
commit 4a1e817855
7 changed files with 48 additions and 6 deletions

6
Question03-if/.classpath Normal file
View 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
View File

@@ -0,0 +1 @@
/bin/

17
Question03-if/.project Normal file
View 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>

View File

@@ -8,9 +8,9 @@ public class PTra03_01 {
public static void main(String[] args) { public static void main(String[] args) {
// TODO int型の変数numを宣言し、100で初期化してください // TODO int型の変数numを宣言し、100で初期化してください
int num = 100;
// TODO「変数numが100である」という条件式を追加してください // TODO「変数numが100である」という条件式を追加してください
if () { if (num == 100) {
System.out.println("条件に合致しました"); System.out.println("条件に合致しました");
} }
} }

View File

@@ -7,9 +7,13 @@
public class PTra03_02 { public class PTra03_02 {
public static void main(String[] args) { public static void main(String[] args) {
// TODO int型の変数numを宣言し、65で初期化してください // TODO int型の変数numを宣言し、65で初期化してください
int num = 65;
// TODO 変数numの値が65以上の場合は「合格です」と出力し、それ以外であれば「不合格です」を出力してください // TODO 変数numの値が65以上の場合は「合格です」と出力し、それ以外であれば「不合格です」を出力してください
// ※ 合格です と表示されれば正解 // ※ 合格です と表示されれば正解
if (num >= 65) {
System.out.println("合格です");
}else {
System.out.println("不合格です");
}
} }
} }

View File

@@ -9,8 +9,10 @@ public class PTra03_03 {
int num = 10; int num = 10;
// TODO numが 2で割り切れる かつ 5で割り切れるという条件式を記述してください // TODO numが 2で割り切れる かつ 5で割り切れるという条件式を記述してください
if () { if ( num%2 == 0 && num%5 == 0 ){
{
System.out.println(num + "は2でも5でも割り切れます。"); System.out.println(num + "は2でも5でも割り切れます。");
} }
} }
} }
}

View File

@@ -4,6 +4,7 @@
*------------------------------------------------------------ *------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved. * Copyright(c) Rhizome Inc. All Rights Reserved.
*/ */
public class PTra03_04 { public class PTra03_04 {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("降水確率を入力してください。(数字のみ)"); System.out.println("降水確率を入力してください。(数字のみ)");
@@ -20,5 +21,16 @@ public class PTra03_04 {
* *
* ※ 変数numの値が 0より小さい または 100より大きい場合は「不正な値が入力されました」と出力してください。 * ※ 変数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("不正な値が入力されました");
}
} }
} }