Beijing Institute of Electronic Technology (BESTI)
Real Inspection report
Lesson: Java Programming Experiment class: 1353 name: Fu Yunjin No.: 20135323
Score: Instructor: Lou Jia Peng Experimental Date: 2015.4.17
Experimental classification: No preview degree: Experimental time: 15:30~18:00
Instrument Group: 23 Compulsory/elective: Elective experiment number: 1
Lab name: Familiarity with the Java Development environment
Experimental purposes and requirements:
1. Compiling and running a simple Java program using the JDK
2. Edit, compile, run, and debug Java programs using Eclipse
3. Achieve student performance management function, and test;
Experimental instrument:
name |
model |
|
< P align= "Center" >pc |
SONY&NBSP; |
1 |
virtual machine |
Lab building |
1 |
Experimental knowledge points
1. Installation location and difference of JVM, JRE, JDK;
2. command line run JAVAC,JAVA;JAVAC-CP; JAVA-CP;
3. Path,classpath,sourcepath setting method and application;
4. Package management: package;import;javac-d;
5. Eclipse (Netbeans) manages Java projects, debugging: breakpoints, stepping, etc.;
6. Java basic syntax: type and type conversion; variables; operators; Process control, etc.;
7. Use of JDK help documentation;
First, the contents of the experiment:
(i) Java program Development under command line
Code:
Package fyj;
Import Java.util.Scanner;
public class Hello
{
public static void Main (string[] args)
{
System.out.println ("Input your first name, please:");
Scanner s = newscanner (system.in);
String name = S.next ();
System.out.println ("Hello" + name + "!");
}
}
Experiment:
Following the experiment in the virtual machine, the results are as follows:
Precautions:
1. Note the first line of the code, which affects how we compile the code using JAVAC.
2. Note the second line of the code, when we use the class in the Java class Library, import the related classes with import (you can temporarily understand the features of the Include in C), and import the path to view the JDK help documentation.
3. Enter javac-d. Hello.java command to compile the code, enter the Java YJX. The Hello command runs the program.
4. Note: When you have a package in your code, you must add the-d parameter when you compile your code with JAVAC, and you must prefix the name of the packet when you run the code.
(ii) Development and commissioning of Java programs under Eclipse
Code:
Package fyj;
public class Hellofyj {
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<100;i++)
Sum+=i;
SYSTEM.OUT.PRINTLN (sum);
}
public static int Add (int augend, int addend) {
int sum = augend + addend;
return sum;
}
}
Experiment:
After you run, debug, and set breakpoints:
(iii) Achievement of student performance management functions and testing
Code:
Import java.util.ArrayList;
Import Java.util.Scanner;
public class Student2
{
public static void Main (string[] args)
{
Scanner input = new Scanner (system.in);
System.out.println ("Please enter the number of students:");
int number = 0;
Number = Input.nextint ();
System.out.println ("Please enter the number of courses:");
int courses = 0;
Courses = Input.nextint ();
string[] Coursesname = new string[courses];
for (int i=0;i<coursesname.length;i++)
{
System.out.println ("Please enter the name of the" + (i+1) + "Door class");
Coursesname[i]=input.next ();
}
Arraylist<student> name=new arraylist<student> ();
int [] [] score = new Int[number][courses];
for (int i=0;i<number;i++)
{
Student fornew=new student ();
Name.add (fornew);
System.out.println ("Please enter" + (i+1) + "Student's name:");
Name.get (i). Name = Input.next ();
System.out.println ("Please enter" + (i+1) + "Student Number:");
Name.get (i). Number = Input.next ();
for (int j=0;j<coursesname.length;j++)
{
System.out.println ("Please enter" +name.get (i). name+ "" +coursesname[j]+ "of the results");
SCORE[I][J] = Input.nextint ();
}
}
int sum = 0;
int[] Scoresum = new Int[number];
int[] ci = new Int[number];
for (int i=0;i<number;i++)
{
for (int j=0;j<courses;j++)
{
Sum + = Score[i][j];
}
Scoresum[i] = sum;
Ci[i] = sum;
sum = 0;
}
for (int i = 0;i<number-1;i++)
{
for (int j=i+1;j<number;j++)
{
if (Ci[i]<ci[j])
{
int temp = Ci[j];
CI[J] = Ci[i];
Ci[i] = temp;
}
}
}
System.out.print ("Student \ T");
System.out.print ("School number \ T");
for (int i=0;i<courses;i++)
{
System.out.print (coursesname[i]+ "\ t");
}
System.out.print ("Total score \ T");
System.out.print ("Average sub-t");
System.out.print ("leaderboard");
System.out.print ("\ n");
int[] temp = new Int[number];
for (int i=0;i<temp.length;i++)
{
for (int j=0;j<scoresum.length;j++)
{
if (ci[i] = = Scoresum[j])
{
Temp[i] = j;
}
}
}
for (int i=0;i<number;i++)
{
System.out.print (Name.get (Temp[i]). name+ "\ t");
System.out.print (Name.get (Temp[i]). number+ "\ t");
for (int j=0;j<courses;j++)
{
System.out.print (score[temp[i]][j]+ "\ t");
}
System.out.print (scoresum[temp[i]]+ "\ t");
System.out.print (scoresum[temp[i]]/courses+ "\ t");
System.out.print ("NO." + (i+1));
System.out.print ("\ n");
}
}
}
Class student{
public String name;
public String number;
}
:
(iv) Experimental summary:
This experiment is the first experiment of the semester, for all the content of the experiment makes me feel the Java course is not studious, but I am full of confidence.
For experiment one, the aim is to familiarize ourselves with the use of virtual machines and to be familiar with scanner. In this experiment, we did not encounter particularly many problems according to the operation.
For experiment two, inserting a breakpoint, this experiment lets me know how to find out if the code is wrong. Breakpoints can effectively isolate the code and quickly find the wrong place.
For the experiment three, 1. My school number is drawn to the student management system, for me is really difficult, because of their Java programming is not fully used, the student management system can do too much content. Finally, in combination with some of their own level, I made a study number, name, subject, total score, average score, ranking of the simple student performance management system.
2. In the experiment I learned to call scanner, which solves the problem of input. But after the input, the problem comes out, how to deal with the input data and realize its function.
3. For students ' attributes, they can be divided into three categories, namely, student number, name, and various subjects ' grades. By this time, I thought of the need to invoke a two-dimensional array. But the two-dimensional array can only invoke the data, and it will not use a multidimensional array, how to synchronize the remaining class with it? This has become a difficult problem for me to solve.
4. For how to solve a class, I went online to find a lot of information, and read a lot of student management system related code, found that they are dealing with this problem with a dynamic array ArrayList. And in the code, I joined the
Class student{
public String name;
public String number;
This is equivalent to the structure of the C language, then using arraylist<student> name=new arraylist<student> (), equivalent to student[], assigning student a capacity The name and number can be stored. So the school number and name are tied together.
5. In the next code, use the Add and get functions in ArrayList. The Add function is responsible for inserting names and learning numbers into the dynamic array, and get is responsible for reading the names and the numbers from the dynamic array output.
6. The rest, such as the overall score, the average and the rankings are similar to the C language and are not mentioned here.
In a word, the experiment prepared itself for a week, consulted a lot of relevant information, really learned a lot, but also hope that the next time I can be more positive, learn more about Java knowledge.
(v) PSP Time Statistics
Steps |
Time-consuming percentage |
Demand analysis |
5% |
Design |
8% |
Code implementation |
70% |
Test |
10% |
Analysis Summary |
7% |
Java Lab report one