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
- Enter the eclipse command on the command line that is already open and return to open eclipse.
- 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.
- 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