mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Updated for sonarqube
This commit is contained in:
@@ -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(){
|
||||
|
||||
Reference in New Issue
Block a user