Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active December 5, 2016 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokomokohitsuzi/58cbbbeff289e0db1a23c4fb76010792 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/58cbbbeff289e0db1a23c4fb76010792 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習6-3
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