mirror of
https://bitbucket.org/Mattrixwv/projecteulerjava.git
synced 2025-12-06 17:13:58 -05:00
Fixed some typoes
This commit is contained in:
@@ -42,7 +42,7 @@ public class Problem17 extends Problem{
|
|||||||
for(int num = START_NUM;num <= STOP_NUM;++num){
|
for(int num = START_NUM;num <= STOP_NUM;++num){
|
||||||
//Pass the number to a function that will create a string for the number
|
//Pass the number to a function that will create a string for the number
|
||||||
String currentNumString = getStringFromNum(num);
|
String currentNumString = getStringFromNum(num);
|
||||||
//Pass the string to ta function that will count the number of letters in it, ignoring whitespace and punctuation and add that number to the running tally
|
//Pass the string to the function that will count the number of letters in it, ignoring whitespace and punctuation and add that number to the running tally
|
||||||
sumOfLetters += getNumberChars(currentNumString);
|
sumOfLetters += getNumberChars(currentNumString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,13 +54,13 @@ public class Problem17 extends Problem{
|
|||||||
}
|
}
|
||||||
private String getStringFromNum(int number){
|
private String getStringFromNum(int number){
|
||||||
String numberString = new String();
|
String numberString = new String();
|
||||||
//Starting with the largest digit create a string based on teh number passed in
|
//Starting with the largest digit create a string based on the number passed in
|
||||||
//Check for negative
|
//Check for negative
|
||||||
if(number < 0){
|
if(number < 0){
|
||||||
numberString = numberString.concat("negative ");
|
numberString = numberString.concat("negative ");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if teh number is zero
|
//Check if the number is zero
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
numberString = numberString.concat("zero");
|
numberString = numberString.concat("zero");
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ public class Problem17 extends Problem{
|
|||||||
|
|
||||||
//Check for tens place
|
//Check for tens place
|
||||||
if((number / 10D) >= 2D){
|
if((number / 10D) >= 2D){
|
||||||
//FOr the tens you need to do something special
|
//For the tens you need to do something special
|
||||||
int tensPlace = (int)Math.floor(number / 10D);
|
int tensPlace = (int)Math.floor(number / 10D);
|
||||||
if(tensPlace == 9){
|
if(tensPlace == 9){
|
||||||
numberString = numberString.concat("ninety");
|
numberString = numberString.concat("ninety");
|
||||||
@@ -115,7 +115,7 @@ public class Problem17 extends Problem{
|
|||||||
number -= (tensPlace * 10);
|
number -= (tensPlace * 10);
|
||||||
//If there is something left in the number you will need a dash to separate the tens and ones place
|
//If there is something left in the number you will need a dash to separate the tens and ones place
|
||||||
if(number > 0){
|
if(number > 0){
|
||||||
numberString = numberString.concat("-");
|
numberString = numberString.concat("-");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Check for teens
|
//Check for teens
|
||||||
|
|||||||
Reference in New Issue
Block a user