Java Lab Report
20135226 Kun Huang
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
Java program development and debugging under Eclipse
In Eclipse, click file->new-> Java Project, enter the project name HELLOJY, and click the Finish button to complete the new project, and in Eclipse, click file->new-> Class new Java class
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 finally click the Finish button. Enter the 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;
}
}
Set breakpoints
(iii) Implementation of arithmetic and testing via command line and Eclipse two methods
Package Perform;
Import Java.util.Scanner;
public class Perform
{
public static void Main (string[] args)
{
Scanner i= New Scanner (system.in);
System.out.println ("Enter the first number");
Double A = i.nextdouble ();
SYSTEM.OUT.PRINTLN ("input operator");
String s = i.next ();
System.out.println ("Enter a second number");
Double b = i.nextdouble ();
if (s.equals ("+"))
{
Double sum;
Sum=a+b;
SYSTEM.OUT.PRINTLN ("Result:" +a+s+b+ "=" +sum);
}
else if (s.equals ("-"))
{
Double sum;
if (a<b)
{
Sum=b-a;
SYSTEM.OUT.PRINTLN ("Result:" +a+s+b+ "=" +sum);
}
else if (a>b)
{
Sum=a-b;
SYSTEM.OUT.PRINTLN ("Result:" +a+s+b+ "=" +sum);
}
}
else if (s.equals ("*"))
{
Double sum;
Sum=a*b;
SYSTEM.OUT.PRINTLN ("Result:" +a+s+b+ "=" +sum);
}
else if (s.equals ("/"))
{
if (a<b)
{
Double sum;
sum=b/a;
SYSTEM.OUT.PRINTLN ("Result:" +a+s+b+ "=" +sum);
}
}
else if (a>b)
{
Double sum=a/b;
SYSTEM.OUT.PRINTLN ("Result:" +a+s+b+ "=" +sum);
}
}
}
(iii) problems encountered and solutions
No
First Java Lab report