Các bài tập workshop và PE có lời giải của ngôn ngữ Java
Chúng mình đã tổng hợp lại các bài workshop và đề mẫu PE của ngôn ngữ Java để các bạn có thể tham khảo tránh việc bỡ ngỡ qua đó có thể luyện tập để có một mùa thi PE tốt đẹp nhất.
Workshop1:
Đề bài:
Write a Java program that will accept a matrix of integers then this matrix will be printed out and the sum of values and average of values are printed also.
The user
interface may be:
Enter number
of rows: 2
Enter number
of columns: 3
Enter the
matrix
m[0][0]=1
m[0][1]=2
m[0][2]=3
m[1][0]=4
m[1][1]=5
m[1][2]=6
Matrix
inputted:
1 2 3
4 5 6
Sum: 21
Average: 3.5
Hint:
Use System.out.format("%3d", n);
Hướng dẫn:
Step1: Input the matrix
Step2: Get the sum of values
Step3: Get the average of values - You will add the code “System.out.println("Average:" +(float)sum/(rows*cols));”
Write a Java program that will accept two
float numbers and an operator (+-*/) then the program will print out the result
of the specified expression that bases on the inputted operator.
The user
interface may be:
Input the number 1: 4
Input the number 2: 5
Input the operator: +
the result of 4+5=9
Hướng dẫn:
-
In the project above, you create a new class
named “Part2.java” and add the code:
-
You must add your
code to get the result when user inputs another operator
PE:
Q1:
Đề bài:
- Class VNMotor.java:
- Class Motor.java:
- Class Main.java:
Q2:
Đề bài:
Solution:
- - Class Printer.java:
- Class MyPrinter.java:
- Class IPrinter.java:
- Class Main.java:
Nhận xét
Đăng nhận xét