Updated for sonarqube

This commit is contained in:
2022-12-04 15:11:32 -05:00
parent 726d800676
commit 8e25c9338f
29 changed files with 356 additions and 616 deletions

View File

@@ -29,7 +29,7 @@ import com.mattrixwv.project_euler.Unsolved;
public class Problem9 extends Problem{
//Variables
//Static variables
private static int GOAL_SUM = 1000; //The number that we want the sum of a, b, and c to equal
private static final int GOAL_SUM = 1000; //The number that we want the sum of a, b, and c to equal
//Instance variables
private int a; //The size of the first side
private int b; //The size of the second side
@@ -61,12 +61,12 @@ public class Problem9 extends Problem{
//Loop through all possible a's
while((a < GOAL_SUM) && !found){
b = a + 1; //b must be larger than a
c = Math.sqrt((a * a) + (b * b)); //Compute the hyp
c = Math.sqrt((a * a) + (double)(b * b)); //Compute the hyp
//Loop through all possible b's for this a
while((a + b + c) < GOAL_SUM){
++b;
c = Math.sqrt((a * a) + (b * b));
c = Math.sqrt((a * a) + (double)(b * b));
}
//If the sum == 1000 you found the number, otherwise go to the next possible a
@@ -104,7 +104,7 @@ public class Problem9 extends Problem{
@Override
public String getResult(){
solvedCheck("result");
return String.format("The Pythagorean triplet is %d + %d + %d\nThe numbers' product is %d", a, b, Math.round(c), a * b * Math.round(c));
return String.format("The Pythagorean triplet is %d + %d + %d%nThe numbers' product is %d", a, b, Math.round(c), a * b * Math.round(c));
}
//Returns the length of the first side
public int getSideA(){