20145307 "Java program design" The first experimental report of the Beijing Institute of Electronic Technology (BESTI) Experimental Report course: Java Programming Class: 1453 Instructor: Lou Jia Peng Experimental Date: 2016.04.08 experiment name: Familiarity with the Java development environment (Linux + Eclipse) Experiment content:
1. Compile and run a simple Java program using the JDK;
2. Edit, compile, run, and debug Java programs using Eclipse.
Experimental purposes and requirements:
Compile and run simple Java programs using the JDK and IDE: Practice topic: the operation and implementation of the Fibonacci sequence
Program Design Ideas:
Constructs a Fibonacci sequence of functions, the return value is fixed before the first two items and just fine. And then the main function refers to him, and it's no hard job.
Code and explanations
import java.util.Scanner; //引用输入语句APIpublic class Fibonacci { //定义Fibonacci类private static int getFibo(int i) { //定义Fibo函数 if (i == 1 || i == 2) //前两项不符合题目条件 return 1; //返回值1 else return getFibo(i - 1) + getFibo(i - 2);} //返回前两项值只和public static void main(String[] args) { //定义主函数 System.out.println("输入斐波那契数列的容量,数列显示如下:"); //用户交互 int Jc;Scanner scanner = new Scanner(System.in); //定义输入计数变量Jc Jc=scanner.nextInt(); //赋值 for (int j = 1; j <= Jc; j++) { System.out.print(getFibo(j) + "\t"); //输出所求值 if (j % 5 == 0) //每五个数值一行,好看 System.out.println();} //换行,好看 } }
Experience
Fortunately, the first experiment simple, and then continue to work hard, but other practice Caesar password I did not do in free time, should pay attention (but I wrote in C language)
20145307 first week Java Lab report