q6-6まで完了
This commit is contained in:
6
Question06-for/.classpath
Normal file
6
Question06-for/.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
Question06-for/.gitignore
vendored
Normal file
1
Question06-for/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
Question06-for/.project
Normal file
17
Question06-for/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question06-for</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,6 +7,10 @@
|
||||
public class PTra06_01 {
|
||||
public static void main(String[] args) {
|
||||
// TODO for文を使って0から99までの整数を順にコンソールに出力してください。
|
||||
|
||||
for(int i = 0; i <= 99; i++){
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ public class PTra06_02 {
|
||||
/*
|
||||
* ■■■■■
|
||||
*/
|
||||
for(int i = 0; i < 5; i++) {
|
||||
System.out.print("■");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ public class PTra06_03 {
|
||||
|
||||
// iが0から100になるまで繰り返しを行います
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
if(i % 2 == 0){
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
|
||||
// TODO iが偶数の時だけ、iの値を出力してください
|
||||
|
||||
|
||||
@@ -14,6 +14,18 @@ public class PTra06_04 {
|
||||
* ④ 上記のいずれにも当てはまらない場合はiの値をそのまま出力する
|
||||
*/
|
||||
for(int i = 1;i < 50;i++) {
|
||||
if(i % 3 == 0) {
|
||||
System.out.println("fizz"); //①処理
|
||||
}
|
||||
if(i % 5 == 0) {
|
||||
System.out.println("buzz"); //②処理
|
||||
}
|
||||
if(i % 3 == 0 && i % 5 == 0) {
|
||||
System.out.println("fizzbuzz"); //③処理
|
||||
}
|
||||
else {
|
||||
System.out.println(i); //④処理
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,12 @@ public class PTra06_05 {
|
||||
// TODO 値が2の場合は出力しないようにしてください。
|
||||
// ※ continueを用いてください。
|
||||
for(int i = 0;i < 10;i++) {
|
||||
randomNumber = random.nextInt(3);
|
||||
|
||||
|
||||
randomNumber = random.nextInt(3);{
|
||||
if(randomNumber == 2) {
|
||||
continue;
|
||||
}
|
||||
// System.out.println(randomNumber);
|
||||
}
|
||||
System.out.println(randomNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
public class PTra06_06 {
|
||||
public static void main(String[] args) {
|
||||
int rows = 5;
|
||||
// TODO for文を使って以下の出力結果が出るようなプログラムを作成してください。
|
||||
/*
|
||||
* ■■■■■
|
||||
@@ -14,7 +15,13 @@ public class PTra06_06 {
|
||||
* ■■■■■
|
||||
* ■■■■■
|
||||
*/
|
||||
|
||||
for(int i = 0; i < rows; i++) {
|
||||
for(int j = 0; j < rows; j++) {
|
||||
System.out.print("■");
|
||||
}
|
||||
// for(int i = 0; i <5; i++) {
|
||||
System.out.println("■");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//for(int i = 0; i <5; i++) {
|
||||
Reference in New Issue
Block a user