【Java】数値の和を求めるプログラミング【アルゴリズム】
プログラムの説明
数値を20個入力し、その和を求めて表示する。
プログラム
◯Calculation()
◯整数型: In, total, i
・total ← 0
(繰り返し)i : 1, i <= 20, 1
・In に数値を入力
・total ← total + In
(繰り返し終了)
・total を出力
Javaでコーディング する
// Calculation.java
public class Calculation {
static int total;
static int In;
static int i;
public static void main(String[] args) {
total = 0;
for(i=1, i<=20, i++) {
In = num;
total= total + In
}
System.out.print(total + "¥t");
}
}
まだよくわかってないのでミスが多いかもしれません。更新していきます。よかったらコメントで言ってくれると助かります。
ディスカッション
コメント一覧
まだ、コメントがありません