we will be using mutation analysis. We have generated many variations of the Demo.java file, each with a single fault introduced. These faults (mutations) include things like swapping a binary operator for another (e.g., ‘+’ instead of ‘-‘), or changing the variable used for another variable of the same type (e.g., ‘a’ substituted for ‘b’). can you help me in These faults (mutations) ?
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
// Reading from System.in
Scanner reader = new Scanner(System.in);
System.out.println("Enter side 1: ");
// Scans the next token of the input as an int.
int side_1 = reader.nextInt();
System.out.println("Enter side 2: ");
// Scans the next token of the input as an int.
int side_2 = reader.nextInt();
System.out.println("Enter side 3: ");
// Scans the next token of the input as an int.
int side_3 = reader.nextInt();
if (isTriangle(side_1, side_2, side_3)) {
System.out.println("This is a triangle.");
}
else {
System.out.println("This is not a triangle.");
}
reader.close();
}
public static boolean isTriangle(double a, double b, double c) {
if ((a + b > c) &&
(a + c > b) &&
(b + c > a)) {
return true;
}
return false;
}
}
I answer the below but failed with mutations test can you help me ?
Mohammad Nouman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1