Java Lab report (20135102 Zhou Yongjie)

Source: Internet
Author: User

First, the contents of the experiment

(i), command-line Java program Development

(ii), under Eclipse Java program development, debugging

(iii) Implementation of arithmetic and testing via command line and Eclipse two methods

Second, the experimental process

(i) Java Program Development under command line

Open the terminal (like cmd in Windows), then run the shell program automatically, enter the CD Code command into code (note C to capitalize) directory.

Enter the mkdir 20135102 command to set up the experimental directory, you can use the LS command or the dir command to view the established directory situation.

Enter the CD 20135102 command into the experimental directory, and then enter a similar mkdir EXP1 to create the first experimental directory, and then enter the CD EXP1 into the experimental directory, you can enter the PWD command to view the current working path

Enter Gedit Hello.java or vim Hello.java, edit Hello.java.

Enter javac-d. Hello.java Command Compile code, enter Java JY. The Hello command runs the program.

Results of the output

(ii), under Eclipse Java program development, debugging

      in eclipse file->new-> java  projectjavahellojy and click button to complete the new project, in eclipse Click file->new->class new java

According to the Java Code Specification input package name JY(lowercase, can be customized), the class name hellojy, and tick the automatically generate main function option, and then click Finish button,. Input code

Package hellojy;

public class Hellojy

{

public static void Main (string[] args)

{

int i = 5;

int j = 6;

int sum = Add (i, j);

SYSTEM.OUT.PRINTLN (sum);

sum = 0;

for (i=0; i<; i++)

sum + = i;

SYSTEM.OUT.PRINTLN (sum);

}

public static int Add (int augend, int addend)

{

int sum = augend + addend;

return sum;

}

}

(iii), the realization of the series

Package Shiyan;

Import Java.util.Scanner;

public class Shiyan {

public static void Main (String [] args)

{

Shuru ();

}

public static void Shuru ()

{

SYSTEM.OUT.PRINTLN ("Input n not less than 2");

Scanner reader = new Scanner (system.in);

try{

int N=reader.nextint ();

if (n>=2)

{

Diaoyong (n);

}

else {

SYSTEM.OUT.PRINTLN ("input error");

Shuru ();

}

}catch (Exception e) {

SYSTEM.OUT.PRINTLN ("input error");

Shuru ();

}

}

public static void Diaoyong (int n)

{

System.out.print ("0 1");

int j=0,a=1,m,b=0;

Do

{

M=a;

A=a+j;

J=m;

b++;

System.out.print ("+a");

}while (b< (n-1)); {

System.out.println ();

}

}

}

Java Lab report (20135102 Zhou Yongjie)

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.