SWT301_-_FA_2023_-_PE1_986.webp
Lan Anh1

SWT301_-_FA_2023_-_PE1_986.webp

  • Media owner Lan Anh1
  • Ngày thêm
to do the test.
Question 1 (3 points): Review the following class and find (at least) 6 issues in the code (i.e.,coding practice, compile errors, potential logical issues, etc.) (Use question I template)
1
2
public class SumEven Numbers {
public static void main(String[] args) {
Scanner scanner new Scanner(System.in);
System.out.print("Enter the starting number: ");
int start scanner.nextInt();
System.out.print("Enter the ending number: ");
int end scanner.nextInt();
int sum = 0;
int average:
for (int i start; i <= end; i++) {
if (i % 2 == 0) {
sum += 1;
}
10
11
12
13
14
15
16
17
18
19
20
System.out.println("The sum of even numbers from start" to "end" is sum);
}
Zoom
21 }
Question 2 (3 points): Assuming you are assigned to conduct the component test for the method below, please design and create the minimum component test cases (Unit Test case) needed to achieve 100% statement coverage and 100% decision coverage. (Use question 2 template).
This code defines a performOperation method that takes two numbers and an operation string as input. It performs the specified operation (addition, subtraction, multiplication, or division) and returns the result. It includes logging for each operation, as well as error handling for various scenarios.
+ 100%
}

Close
Chưa có bình luận nào.

Thông tin

Category
SWT301
Thêm bởi
Lan Anh1
Ngày thêm
Lượt xem
1,780
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
SWT301_-_FA_2023_-_PE1_986.webp
File size
64.8 KB
Dimensions
1552px x 700px

Share this media

Back
Bên trên Bottom