Last active
December 5, 2016 13:16
-
-
Save mokomokohitsuzi/58cbbbeff289e0db1a23c4fb76010792 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習6-3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class En06_03 { | |
public static void main(String[] args) { | |
//MAXの値を変更できるように変数にする | |
final int MAX =5; | |
//double型の配列を作成 | |
double[] a = new double[MAX]; | |
for (int i = 0; i < a.length; i++) { | |
//1の位を作成 | |
int j = i + 1; | |
//小数点のループは誤差が出るため、一旦整数で計算する | |
double n = (j * 11); | |
//nを1/10した値を配列へ代入する。 | |
a[i] = (double) (n/10); | |
System.out.println(a[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment