1.6(数列求和)编写程序,显示1+2+3+4+5+6+7+8+9的结果。
1.6 (Summation of a series) Write a program that displays the result of 1+2+3+4+5+6+7+8+9.
下面是参考答案代码:
public class SummationSequenceNumbersQuestion6 {
public static void main(String[] args) {
System.out.println("The sum of the sequence : "+ (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9));
}
}
运行结果:
注:编程程序要养成良好习惯
如:1.文件名要用英文,具体一点
2.注释要英文
3.变量命名要具体,不要抽象(如:a,b,c等等),形式要驼峰化
4.整体书写风格要统一(不要这里是驼峰,那里是下划线,这里的逻辑段落空三行,那里相同的逻辑段落空5行等等)