20135239 First experimental report

Source: Internet
Author: User

Lab Report

First, the contents of the experiment

1. Compiling and running a simple Java program using the JDK

2. Edit, compile, run, and debug Java programs using Eclipse

Requirements:

Complete the experiment and write the experiment report

Statistics PSP Time

Second, the experimental process

Compile and run a simple Java program using the JDK

1. After entering the lab environment, open the Xfce terminal. It acts like a cmd command line to open and execute certain programs.

2. Enter CD Java0217->mkdir 20135239->cd 20135239->mkdir expel1->cd expel1->gedit Hello.java A series of steps in the directory " 20135239\expel1\ "To create a Hello Java file. At this point, it pops up.

Write the program and then debug the program and run the results out.

Enter the code of the Hello

Package LJP;
Import Java.util.Scanner;
public class Hello
{
public static void Main (string[] args)
{
System.out.println ("Input your first name, please:");
Scanner s = new Scanner (system.in);
String name = S.next ();
System.out.println ("Hello" + name + "!");
}
}

Use Eclipse to edit, compile, run, and debug Java programs

    1. Enter the eclipse command on the command line that is already open and return to open eclipse.
    2. In Eclipse, click File->new-> Java Project to build a project called Hello, and in accordance with File->new->class, create a package name LWR, class name Hello, and tick the Automatically generate main function option, and then click the Finish button.
    3. Enter the following code

Package LWR;

public class Hellojdb {

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;

}

}

Practice:

5. To achieve the 1-n of all prime numbers between positive integer

1. Command line implementation:

First, the code is


Package LJP;
Import Java.util.Scanner;
public class Zhishu
{
public static int x;

public static void Main (string[] args)
{
System.out.print ("Enter a number:");
Scanner s=new Scanner (system.in);
int x = S.nextint ();
System.out.println ("prime numbers smaller than this number:");
for (int i=1;i<=x;i++)
{
if (i==1)
System.out.print (i+ "");
else for (int j=2;j<i;j++)
{
if (i%j==0)
Break

if (j==i-1 && j!=x-1)
System.out.print (i+ "");


}

}



}
}

Third, the experimental problems and experience.

The experiment is that the virtual machine is too slow.

Typing a format on the command line often makes an error. But the correction came.

Eclipse is not yet familiar. And the last time I set a conditional breakpoint, I didn't know exactly what he was showing. So I didn't get a clear picture of the cut at this time.

But I will work hard. will be getting better.

Steps

time-consuming ( min )

Percentage

Demand analysis

20

11.1%

Design

35

19.4%

Code implementation

70

38.9%

Test

25

13.9%

Analysis Summary

30

16.7%

20135239 First experimental 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.