20145307 first week Java Lab report

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.