From d7ae05617a26a72fe49d2828a1260d2a47c4f0b3 Mon Sep 17 00:00:00 2001 From: Terence Zhao Date: Tue, 11 Jul 2017 01:04:27 +0000 Subject: [PATCH 1/3] Solved word count --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0df2d0f..d087423 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,7 +11,7 @@ def word_count # ================================================================================ - @word_count = "Replace this string with your answer." + @word_count = @text.split.count @character_count_with_spaces = "Replace this string with your answer." From 8ddfc81e5a9b28cea113c95861d4c154f9995ece Mon Sep 17 00:00:00 2001 From: Terence Zhao Date: Tue, 11 Jul 2017 04:59:31 +0000 Subject: [PATCH 2/3] finished word_count implementation --- app/controllers/calculations_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index d087423..ecfc6f9 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -13,11 +13,11 @@ def word_count @word_count = @text.split.count - @character_count_with_spaces = "Replace this string with your answer." + @character_count_with_spaces = @text.length - @character_count_without_spaces = "Replace this string with your answer." + @character_count_without_spaces = @text.gsub(' ', '').length - @occurrences = "Replace this string with your answer." + @occurrences = @text.scan(@special_word).length # ================================================================================ # Your code goes above. From 50adfaac759ae7e47792c852e68b775e8e67cc4d Mon Sep 17 00:00:00 2001 From: Terence Zhao Date: Tue, 11 Jul 2017 05:47:20 +0000 Subject: [PATCH 3/3] Implemented monthly payment calculation --- app/controllers/calculations_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index ecfc6f9..69119c2 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -17,7 +17,7 @@ def word_count @character_count_without_spaces = @text.gsub(' ', '').length - @occurrences = @text.scan(@special_word).length + @occurrences = @text.downcase.scan(@special_word.downcase).length # ================================================================================ # Your code goes above. @@ -38,7 +38,7 @@ def loan_payment # The principal value the user input is in the decimal @principal. # ================================================================================ - @monthly_payment = "Replace this string with your answer." + @monthly_payment = ((@apr/100/12 * @principal) / (1 - (1 + @apr/100/12)**(-@years*12))) # ================================================================================ # Your code goes above.