From 8a6658f3a08797b6bc66797b88e2963edf10acb2 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Thu, 13 Jul 2017 01:46:14 +0000 Subject: [PATCH 01/46] Square Calculation form & button --- Gemfile.lock | 6 +++++- app/controllers/calculations_controller.rb | 19 +++++++++++++++++++ .../flexible_square_template.html.erb | 7 +++++++ .../square_form_template.html.erb | 13 +++++++++++++ config/routes.rb | 6 ++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 app/controllers/calculations_controller.rb create mode 100644 app/views/calculations/flexible_square_template.html.erb create mode 100644 app/views/calculations/square_form_template.html.erb diff --git a/Gemfile.lock b/Gemfile.lock index 9fb5fb6..da4ede5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -208,7 +208,11 @@ GEM rspec-support (3.6.0) ruby_dep (1.5.0) safe_yaml (1.0.4) - sass (3.4.25) + sass (3.5.0) + sass-listen (~> 3.0.7) + sass-listen (3.0.7) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9.7) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb new file mode 100644 index 0000000..781db93 --- /dev/null +++ b/app/controllers/calculations_controller.rb @@ -0,0 +1,19 @@ +class CalculationsController < ApplicationController + def flex_square + # The incoming parameters for this action look like {"a_number"=>"5"} + # Rails stores that hash in a variable called params + + @user_number = params["a_number"].to_i + @squared_number = @user_number**2 + + render("calculations/flexible_square_template.html.erb") + end + + def square_form + + + render("calculations/square_form_template.html.erb") + end + +end + diff --git a/app/views/calculations/flexible_square_template.html.erb b/app/views/calculations/flexible_square_template.html.erb new file mode 100644 index 0000000..47a8d9b --- /dev/null +++ b/app/views/calculations/flexible_square_template.html.erb @@ -0,0 +1,7 @@ +

Flexible Square

+ +

The square of <%= @user_numnber %> is <%= @squared_numnber %>.

+ +<%= number_to_percentage(200) %> + +<%= number_to_currency(200) %> \ No newline at end of file diff --git a/app/views/calculations/square_form_template.html.erb b/app/views/calculations/square_form_template.html.erb new file mode 100644 index 0000000..6d26ea3 --- /dev/null +++ b/app/views/calculations/square_form_template.html.erb @@ -0,0 +1,13 @@ +

Square Calculation

+ +
+
+ + + +
+ + +
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 8015e08..bf547a9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,10 @@ Rails.application.routes.draw do + + get("/flexible/square/:a_number", { :controller => "calculations", :action => "flex_square" }) + + get("/square/new", { :controller => "calculations", :action => "square_form" }) + + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html mount WebGit::Engine, at: "/rails/git" end From 5f1826ed92c296956004cd201e71cd8afe300556 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 00:31:26 +0000 Subject: [PATCH 02/46] setup and forms/templates --- Gemfile.lock | 10 ++-- app/controllers/calculations_controller.rb | 46 +++++++++++++++++-- .../flexible_payment_template.html.erb | 3 ++ .../flexible_random_number_template.html.erb | 3 ++ .../flexible_square_root_template.html.erb | 3 ++ .../flexible_square_template.html.erb | 6 +-- .../payment_form_template.html.erb | 30 ++++++++++++ .../process_square_template.html.erb | 0 .../process_stats_template.html.erb | 0 .../process_wordcount_template.html.erb | 0 .../random_form_template.html.erb | 0 .../square_form_template.html.erb | 8 +++- .../square_results_template.html.erb | 3 ++ config/routes.rb | 13 ++++++ 14 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 app/views/calculations/flexible_payment_template.html.erb create mode 100644 app/views/calculations/flexible_random_number_template.html.erb create mode 100644 app/views/calculations/flexible_square_root_template.html.erb create mode 100644 app/views/calculations/payment_form_template.html.erb create mode 100644 app/views/calculations/process_square_template.html.erb create mode 100644 app/views/calculations/process_stats_template.html.erb create mode 100644 app/views/calculations/process_wordcount_template.html.erb create mode 100644 app/views/calculations/random_form_template.html.erb create mode 100644 app/views/calculations/square_results_template.html.erb diff --git a/Gemfile.lock b/Gemfile.lock index da4ede5..869c6ae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -208,11 +208,11 @@ GEM rspec-support (3.6.0) ruby_dep (1.5.0) safe_yaml (1.0.4) - sass (3.5.0) - sass-listen (~> 3.0.7) - sass-listen (3.0.7) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9.7) + sass (3.5.1) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 781db93..627656e 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -9,11 +9,51 @@ def flex_square render("calculations/flexible_square_template.html.erb") end + def flex_square_root + # The incoming parameters for this action look like {"a_number"=>"5"} + # Rails stores that hash in a variable called params + + @user_number = params["a_number"].to_i + @squared_root = Math.sqrt(@user_number) + + render("calculations/flexible_square_template.html.erb") + end + def square_form - - - render("calculations/square_form_template.html.erb") + + render("calculations/square_form_template.html.erb") + end + + def process_square + # The incoming parameters for this action look like {"the_user_number"=>"5"} + # Rails stores that hash in a variable called params + + @user_number = params["the_user_number"].to_i + @squared_number = @user_number**2 + + render("calculations/square_results_template.html.erb") end + def payment_form + + interest_rate/years/present_value + + # @apr = params["interest_rate"].to_i + # @number_of_years = + # @principal = + + + # monthly_interest = (@apr/12)/100 + # number_of_monthly_payments = @years*-12 + + # @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) + + render("calculations/payment_form_template.html.erb") + end + + + + + end diff --git a/app/views/calculations/flexible_payment_template.html.erb b/app/views/calculations/flexible_payment_template.html.erb new file mode 100644 index 0000000..fd75b5a --- /dev/null +++ b/app/views/calculations/flexible_payment_template.html.erb @@ -0,0 +1,3 @@ +

Flexible Payment

+ +

A <%= @number_of_years %> year loan of <%= @principal %>, with an interest rate of is <%= @apr %>, requires a monthly payment of <%= @monthly_payment %>

\ No newline at end of file diff --git a/app/views/calculations/flexible_random_number_template.html.erb b/app/views/calculations/flexible_random_number_template.html.erb new file mode 100644 index 0000000..07711a2 --- /dev/null +++ b/app/views/calculations/flexible_random_number_template.html.erb @@ -0,0 +1,3 @@ +

Flexible Random Number

+ +

A random number between <%= 50 %> and <%= 100 %>is <%= @random_number %>.

\ No newline at end of file diff --git a/app/views/calculations/flexible_square_root_template.html.erb b/app/views/calculations/flexible_square_root_template.html.erb new file mode 100644 index 0000000..85efe3b --- /dev/null +++ b/app/views/calculations/flexible_square_root_template.html.erb @@ -0,0 +1,3 @@ +

Flexible Square Root

+ +

The square root of <%= @user_number %> is <%= @squared_root %>.

\ No newline at end of file diff --git a/app/views/calculations/flexible_square_template.html.erb b/app/views/calculations/flexible_square_template.html.erb index 47a8d9b..7c0c4ff 100644 --- a/app/views/calculations/flexible_square_template.html.erb +++ b/app/views/calculations/flexible_square_template.html.erb @@ -1,7 +1,7 @@

Flexible Square

-

The square of <%= @user_numnber %> is <%= @squared_numnber %>.

+

The square of <%= @user_number %> is <%= @squared_number %>.

-<%= number_to_percentage(200) %> + -<%= number_to_currency(200) %> \ No newline at end of file + \ No newline at end of file diff --git a/app/views/calculations/payment_form_template.html.erb b/app/views/calculations/payment_form_template.html.erb new file mode 100644 index 0000000..a91161d --- /dev/null +++ b/app/views/calculations/payment_form_template.html.erb @@ -0,0 +1,30 @@ +

Payment Calculation

+ +
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +
+ diff --git a/app/views/calculations/process_square_template.html.erb b/app/views/calculations/process_square_template.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/calculations/process_stats_template.html.erb b/app/views/calculations/process_stats_template.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/calculations/process_wordcount_template.html.erb b/app/views/calculations/process_wordcount_template.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/calculations/random_form_template.html.erb b/app/views/calculations/random_form_template.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/calculations/square_form_template.html.erb b/app/views/calculations/square_form_template.html.erb index 6d26ea3..4ac3752 100644 --- a/app/views/calculations/square_form_template.html.erb +++ b/app/views/calculations/square_form_template.html.erb @@ -6,8 +6,12 @@ Enter a number - + - \ No newline at end of file + + + + Go to Google + \ No newline at end of file diff --git a/app/views/calculations/square_results_template.html.erb b/app/views/calculations/square_results_template.html.erb new file mode 100644 index 0000000..b09050e --- /dev/null +++ b/app/views/calculations/square_results_template.html.erb @@ -0,0 +1,3 @@ +

Square Form Results

+ +

The square of <%= @user_number %> is <%= @squared_number %>.

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bf547a9..8f36dfa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,8 +2,21 @@ get("/flexible/square/:a_number", { :controller => "calculations", :action => "flex_square" }) + get("/flexible/square_root/:a_number", { :controller => "calculations", :action => "flex_square_root" }) + get("/square/new", { :controller => "calculations", :action => "square_form" }) + get("/square/results", { :controller => "calculations", :action => "process_square" }) + + get("/payment/interest_rate/years/present_value", { :controller => "calculations", :action => "payment_form" }) + + get("/random/results", { :controller => "calculations", :action => "random_form" }) + + get("/word_count/results", { :controller => "calculations", :action => "process_wordcount" }) + + get("/descriptive_stats/results", { :controller => "calculations", :action => "process_stats" }) + + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html mount WebGit::Engine, at: "/rails/git" From bfbf802e249f6a282538a16deb4438f2788d3aaa Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 00:56:47 +0000 Subject: [PATCH 03/46] forms and results --- app/controllers/calculations_controller.rb | 27 +++++++++++++++++-- .../square_form_template.html.erb | 2 +- .../square_results_template.html.erb | 21 +++++++++++++-- .../square_root_form_template.html.erb | 17 ++++++++++++ .../square_root_results_template.html.erb | 20 ++++++++++++++ config/routes.rb | 10 ++++++- 6 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 app/views/calculations/square_root_form_template.html.erb create mode 100644 app/views/calculations/square_root_results_template.html.erb diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 627656e..984ff55 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -10,8 +10,6 @@ def flex_square end def flex_square_root - # The incoming parameters for this action look like {"a_number"=>"5"} - # Rails stores that hash in a variable called params @user_number = params["a_number"].to_i @squared_root = Math.sqrt(@user_number) @@ -19,6 +17,31 @@ def flex_square_root render("calculations/flexible_square_template.html.erb") end + def flex_payment + + @monthly_interest = (params["a_number"].to_i) + @number_of_monthly_payments = @years*-12 + + @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) + + render("calculations/flexible_square_template.html.erb") + end + + def flex_random_number + + @random_number = rand(100)-rand(50) + + # random number between 50 & 100 + + render("calculations/flexible_square_template.html.erb") + end + + + + + + + def square_form render("calculations/square_form_template.html.erb") diff --git a/app/views/calculations/square_form_template.html.erb b/app/views/calculations/square_form_template.html.erb index 4ac3752..626f592 100644 --- a/app/views/calculations/square_form_template.html.erb +++ b/app/views/calculations/square_form_template.html.erb @@ -13,5 +13,5 @@ - Go to Google + \ No newline at end of file diff --git a/app/views/calculations/square_results_template.html.erb b/app/views/calculations/square_results_template.html.erb index b09050e..f3173c6 100644 --- a/app/views/calculations/square_results_template.html.erb +++ b/app/views/calculations/square_results_template.html.erb @@ -1,3 +1,20 @@ -

Square Form Results

+

Square Results

-

The square of <%= @user_number %> is <%= @squared_number %>.

\ No newline at end of file +
+

Number

+
+ + + + + +
+

Square

+
+ + + + + + + Calculate another square \ No newline at end of file diff --git a/app/views/calculations/square_root_form_template.html.erb b/app/views/calculations/square_root_form_template.html.erb new file mode 100644 index 0000000..4ac3752 --- /dev/null +++ b/app/views/calculations/square_root_form_template.html.erb @@ -0,0 +1,17 @@ +

Square Calculation

+ +
+
+ + + +
+ + +
+ + + Go to Google + \ No newline at end of file diff --git a/app/views/calculations/square_root_results_template.html.erb b/app/views/calculations/square_root_results_template.html.erb new file mode 100644 index 0000000..717fb17 --- /dev/null +++ b/app/views/calculations/square_root_results_template.html.erb @@ -0,0 +1,20 @@ +

Square Results

+ +
+

Number

+
+ + + + + +
+

Square Root

+
+ + + + + + + Calculate another square root \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 8f36dfa..7aa536f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,9 +4,17 @@ get("/flexible/square_root/:a_number", { :controller => "calculations", :action => "flex_square_root" }) + get("/flexible/payment/:interest_rate/:years/:principal/", { :controller => "calculations", :action => "flex_payment" }) + + get("/flexible/random/:@random_number", { :controller => "calculations", :action => "flex_random" }) + + + get("/square/new", { :controller => "calculations", :action => "square_form" }) - get("/square/results", { :controller => "calculations", :action => "process_square" }) + get("/square/results", { :controller => "calculations", :action => "process_square_root_form" }) + + get("/square/results", { :controller => "calculations", :action => "process_square_root_form" }) get("/payment/interest_rate/years/present_value", { :controller => "calculations", :action => "payment_form" }) From c8aec2dc34d0021b988d7c42ad0220d79de38e3c Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 01:23:02 +0000 Subject: [PATCH 04/46] forms and results templates --- app/controllers/calculations_controller.rb | 4 +- .../payment_form_template.html.erb | 2 +- .../payment_results_template.html.erb | 35 +++++++++++++++ .../process_square_template.html.erb | 0 .../process_stats_template.html.erb | 0 .../process_wordcount_template.html.erb | 0 .../random_form_template.html.erb | 0 .../random_number_form_template.html.erb | 22 ++++++++++ .../random_number_results_template.html.erb | 27 ++++++++++++ .../square_root_form_template.html.erb | 4 +- .../square_root_results_template.html.erb | 2 +- .../calculations/stats_form_template.html.erb | 30 +++++++++++++ .../stats_results_template.html.erb | 35 +++++++++++++++ .../word_count_form_template.html.erb | 23 ++++++++++ .../word_count_results_template.html.erb | 43 +++++++++++++++++++ 15 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 app/views/calculations/payment_results_template.html.erb delete mode 100644 app/views/calculations/process_square_template.html.erb delete mode 100644 app/views/calculations/process_stats_template.html.erb delete mode 100644 app/views/calculations/process_wordcount_template.html.erb delete mode 100644 app/views/calculations/random_form_template.html.erb create mode 100644 app/views/calculations/random_number_form_template.html.erb create mode 100644 app/views/calculations/random_number_results_template.html.erb create mode 100644 app/views/calculations/stats_form_template.html.erb create mode 100644 app/views/calculations/stats_results_template.html.erb create mode 100644 app/views/calculations/word_count_form_template.html.erb create mode 100644 app/views/calculations/word_count_results_template.html.erb diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 984ff55..cdef742 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -17,7 +17,7 @@ def flex_square_root render("calculations/flexible_square_template.html.erb") end - def flex_payment + def flex_payment @monthly_interest = (params["a_number"].to_i) @number_of_monthly_payments = @years*-12 @@ -27,7 +27,7 @@ def flex_payment render("calculations/flexible_square_template.html.erb") end - def flex_random_number + def flex_random_number @random_number = rand(100)-rand(50) diff --git a/app/views/calculations/payment_form_template.html.erb b/app/views/calculations/payment_form_template.html.erb index a91161d..abffadf 100644 --- a/app/views/calculations/payment_form_template.html.erb +++ b/app/views/calculations/payment_form_template.html.erb @@ -14,7 +14,7 @@ Number of Years - +
diff --git a/app/views/calculations/payment_results_template.html.erb b/app/views/calculations/payment_results_template.html.erb new file mode 100644 index 0000000..b6ccc43 --- /dev/null +++ b/app/views/calculations/payment_results_template.html.erb @@ -0,0 +1,35 @@ +

Payment Results

+ +
+

APR

+
+ + + + + +
+

Number of years

+
+ + + + + +
+

Principal

+
+ + + + + +
+

Payment

+
+ + + + + + Calculate another payment \ No newline at end of file diff --git a/app/views/calculations/process_square_template.html.erb b/app/views/calculations/process_square_template.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/calculations/process_stats_template.html.erb b/app/views/calculations/process_stats_template.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/calculations/process_wordcount_template.html.erb b/app/views/calculations/process_wordcount_template.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/calculations/random_form_template.html.erb b/app/views/calculations/random_form_template.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/calculations/random_number_form_template.html.erb b/app/views/calculations/random_number_form_template.html.erb new file mode 100644 index 0000000..b8eb05c --- /dev/null +++ b/app/views/calculations/random_number_form_template.html.erb @@ -0,0 +1,22 @@ +

Random Calculation

+ +
+
+ + + +
+ +
+ + + +
+ + +
+ diff --git a/app/views/calculations/random_number_results_template.html.erb b/app/views/calculations/random_number_results_template.html.erb new file mode 100644 index 0000000..e774d16 --- /dev/null +++ b/app/views/calculations/random_number_results_template.html.erb @@ -0,0 +1,27 @@ +

Random Results

+ +
+

Minimum

+
+ + + + + +
+

Maximum

+
+ + + + + +
+

Random Number

+
+ + + + + + Pick another random number \ No newline at end of file diff --git a/app/views/calculations/square_root_form_template.html.erb b/app/views/calculations/square_root_form_template.html.erb index 4ac3752..51a4fc5 100644 --- a/app/views/calculations/square_root_form_template.html.erb +++ b/app/views/calculations/square_root_form_template.html.erb @@ -1,4 +1,4 @@ -

Square Calculation

+

Square Root Calculation

@@ -9,7 +9,7 @@
- +
diff --git a/app/views/calculations/square_root_results_template.html.erb b/app/views/calculations/square_root_results_template.html.erb index 717fb17..ebe07df 100644 --- a/app/views/calculations/square_root_results_template.html.erb +++ b/app/views/calculations/square_root_results_template.html.erb @@ -1,4 +1,4 @@ -

Square Results

+

Square Root Results

Number

diff --git a/app/views/calculations/stats_form_template.html.erb b/app/views/calculations/stats_form_template.html.erb new file mode 100644 index 0000000..abffadf --- /dev/null +++ b/app/views/calculations/stats_form_template.html.erb @@ -0,0 +1,30 @@ +

Payment Calculation

+ +
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +
+ diff --git a/app/views/calculations/stats_results_template.html.erb b/app/views/calculations/stats_results_template.html.erb new file mode 100644 index 0000000..b6ccc43 --- /dev/null +++ b/app/views/calculations/stats_results_template.html.erb @@ -0,0 +1,35 @@ +

Payment Results

+ +
+

APR

+
+ + + + + +
+

Number of years

+
+ + + + + +
+

Principal

+
+ + + + + +
+

Payment

+
+ + + + + + Calculate another payment \ No newline at end of file diff --git a/app/views/calculations/word_count_form_template.html.erb b/app/views/calculations/word_count_form_template.html.erb new file mode 100644 index 0000000..a10f4a9 --- /dev/null +++ b/app/views/calculations/word_count_form_template.html.erb @@ -0,0 +1,23 @@ +

Word Count Calculation

+ +
+
+ + + +
+ +
+ + + +
+ + + +
+ diff --git a/app/views/calculations/word_count_results_template.html.erb b/app/views/calculations/word_count_results_template.html.erb new file mode 100644 index 0000000..003a43f --- /dev/null +++ b/app/views/calculations/word_count_results_template.html.erb @@ -0,0 +1,43 @@ +

Word Count Results

+ +
+

Text

+
+ + + + + +
+

Word Count

+
+ + + + + +
+

Character Count (with spaces)

+
+ + + + + +
+

Character Count (without spaces)

+
+ + + + + +
+

Occurances of @special_word

+
+ + + + + + Process more text \ No newline at end of file From 6571715b6c55ee58ea191cd913f227ae3a5c5620 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 01:32:01 +0000 Subject: [PATCH 05/46] all forms and results templates are complete --- .../calculations/stats_form_template.html.erb | 23 +---- .../stats_results_template.html.erb | 89 +++++++++++++++++-- 2 files changed, 84 insertions(+), 28 deletions(-) diff --git a/app/views/calculations/stats_form_template.html.erb b/app/views/calculations/stats_form_template.html.erb index abffadf..bc65b99 100644 --- a/app/views/calculations/stats_form_template.html.erb +++ b/app/views/calculations/stats_form_template.html.erb @@ -1,30 +1,15 @@ -

Payment Calculation

+

Stats Calculation

- +
-
- - - -
-
- - - -
- - +
diff --git a/app/views/calculations/stats_results_template.html.erb b/app/views/calculations/stats_results_template.html.erb index b6ccc43..03b6fb6 100644 --- a/app/views/calculations/stats_results_template.html.erb +++ b/app/views/calculations/stats_results_template.html.erb @@ -1,35 +1,106 @@

Payment Results

-

APR

+

Numbers Entered

- + +
-

Number of years

+

Sorted Numbers

- + + + + +
+

Count

+
+ + + + + + +
+

Minimum

+
+ + + + + +
+

Maximum

+
+ + + +
-

Principal

+

Range

- + +
-

Payment

+

Median

- + - Calculate another payment \ No newline at end of file + +
+

Sum

+
+ + + + + +
+

Mean

+
+ + + + + +
+

Variance

+
+ + + + + +
+

Standard Deviation

+
+ + + + + +
+

Mode

+
+ + + + + + + Calculate another Descriptive Stats \ No newline at end of file From 7a7746329c1d023770379a4c3c8a194cbcbe8686 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 01:48:09 +0000 Subject: [PATCH 06/46] gets and forms complete --- app/controllers/calculations_controller.rb | 67 +++++++++++++++++++++- config/routes.rb | 18 +++--- 2 files changed, 75 insertions(+), 10 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index cdef742..10c3387 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -47,7 +47,7 @@ def square_form render("calculations/square_form_template.html.erb") end - def process_square + def square_results # The incoming parameters for this action look like {"the_user_number"=>"5"} # Rails stores that hash in a variable called params @@ -57,7 +57,31 @@ def process_square render("calculations/square_results_template.html.erb") end + + + def square_root_form + + render("calculations/square_form_template.html.erb") + end + + def square_root_results + # The incoming parameters for this action look like {"the_user_number"=>"5"} + # Rails stores that hash in a variable called params + + @user_number = params["the_user_number"].to_i + @squared_root = Math.sqrt(@user_number) + + render("calculations/square_results_template.html.erb") + end + + + def payment_form + + render("calculations/payment_form_template.html.erb") + end + + def payment_results interest_rate/years/present_value @@ -71,11 +95,50 @@ def payment_form # @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) - render("calculations/payment_form_template.html.erb") + render("calculations/payment_results_template.html.erb") + end + + + + def random_number_form + + render("calculations/random_number_form_template.html.erb") + end + + def random_number_results + + + + render("calculations/random_number_results_template.html.erb") + end + + + + def word_count_form + + render("calculations/word_count_form_template.html.erb") end + def random_number_results + + + + render("calculations/word_count_results_template.html.erb") + end + + + def stats_form + + render("calculations/stats_form_template.html.erb") + end + def stats_results + + + + render("calculations/stats_results_template.html.erb") + end end diff --git a/config/routes.rb b/config/routes.rb index 7aa536f..dd45a65 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,23 +6,25 @@ get("/flexible/payment/:interest_rate/:years/:principal/", { :controller => "calculations", :action => "flex_payment" }) - get("/flexible/random/:@random_number", { :controller => "calculations", :action => "flex_random" }) + get("/flexible/random/:@random_number", { :controller => "calculations", :action => "flex_random_number" }) get("/square/new", { :controller => "calculations", :action => "square_form" }) - get("/square/results", { :controller => "calculations", :action => "process_square_root_form" }) - - get("/square/results", { :controller => "calculations", :action => "process_square_root_form" }) - + get("/square/results", { :controller => "calculations", :action => "square_root_form" }) + get("/payment/interest_rate/years/present_value", { :controller => "calculations", :action => "payment_form" }) - get("/random/results", { :controller => "calculations", :action => "random_form" }) + get("/random/results", { :controller => "calculations", :action => "random_number_form" }) + + + + get("/word_count/results", { :controller => "calculations", :action => "word_count_form" }) + + get("/descriptive_stats/results", { :controller => "calculations", :action => "stats_form" }) - get("/word_count/results", { :controller => "calculations", :action => "process_wordcount" }) - get("/descriptive_stats/results", { :controller => "calculations", :action => "process_stats" }) From 1edc8d9ccfaef535b1599b81b060219e897fb8a6 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 02:46:38 +0000 Subject: [PATCH 07/46] linking everything together --- app/controllers/calculations_controller.rb | 170 ++++++++++++++---- .../flexible_payment_template.html.erb | 2 +- .../flexible_random_number_template.html.erb | 3 - .../flexible_square_root_template.html.erb | 2 +- .../flexible_square_template.html.erb | 2 +- .../payment_results_template.html.erb | 24 +-- .../random_number_results_template.html.erb | 18 +- .../square_results_template.html.erb | 12 +- .../square_root_form_template.html.erb | 2 - .../square_root_results_template.html.erb | 12 +- .../stats_results_template.html.erb | 72 ++++---- .../word_count_results_template.html.erb | 30 ++-- config/routes.rb | 22 ++- 13 files changed, 237 insertions(+), 134 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 10c3387..9ce4178 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -3,37 +3,49 @@ def flex_square # The incoming parameters for this action look like {"a_number"=>"5"} # Rails stores that hash in a variable called params - @user_number = params["a_number"].to_i - @squared_number = @user_number**2 + @user_number_flex = params["a_number_flex"].to_i + @squared_number_flex = @user_number_flex**2 render("calculations/flexible_square_template.html.erb") end + def flex_square_root - @user_number = params["a_number"].to_i - @squared_root = Math.sqrt(@user_number) + @user_square_root_number_flex = params["square_root_number_flex"].to_i + @square_root_flex = Math.sqrt(@user_square_root_number_flex) render("calculations/flexible_square_template.html.erb") end + def flex_payment - @monthly_interest = (params["a_number"].to_i) - @number_of_monthly_payments = @years*-12 + @monthly_interest_basispoints_flex = (params["interest_rate_flex"].to_i) + @number_of_years_flex = (params["years_flex"].to_i) + @principal_flex = (params["principal_flex"].to_i) + + + @number_of_monthly_payments_flex = @number_of_years_flex*-12 + + @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/100 + + @monthly_interest_flex = @monthly_interest_percentage_flex/12 - @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) + @monthly_payment_flex = @principal_flex*(@monthly_interest_flex/(1-(1+@monthly_interest_flex)**@number_of_monthly_payments_flex)) - render("calculations/flexible_square_template.html.erb") + render("calculations/flexible_payment_template.html.erb") end + def flex_random_number - @random_number = rand(100)-rand(50) + @random_number_flex = params["random_number_flex"].to_i + @random_number_output_flex = rand(100)-rand(50) # random number between 50 & 100 - render("calculations/flexible_square_template.html.erb") + render("calculations/flexible_random_number_template.html.erb") end @@ -44,15 +56,16 @@ def flex_random_number def square_form + @user_number = params["a_number"].to_i + @squared_number = @user_number**2 + render("calculations/square_form_template.html.erb") end def square_results - # The incoming parameters for this action look like {"the_user_number"=>"5"} - # Rails stores that hash in a variable called params - @user_number = params["the_user_number"].to_i - @squared_number = @user_number**2 + @user_number_root = params["a_number"].to_i + @squared_number = @user_number_root**2 render("calculations/square_results_template.html.erb") end @@ -61,15 +74,16 @@ def square_results def square_root_form + @user_number_root = params["square_root_number"].to_i + @squared_root = Math.sqrt(@user_number_root) + render("calculations/square_form_template.html.erb") end def square_root_results - # The incoming parameters for this action look like {"the_user_number"=>"5"} - # Rails stores that hash in a variable called params - @user_number = params["the_user_number"].to_i - @squared_root = Math.sqrt(@user_number) + @user_number_root = params["square_root_number"].to_i + @squared_root = Math.sqrt(@user_number_root) render("calculations/square_results_template.html.erb") end @@ -78,22 +92,40 @@ def square_root_results def payment_form + # interest_rate/years/present_value + + @monthly_interest_basispoints = (params["interest_rate"].to_i) + @number_of_years = (params["years"].to_i) + @principal = (params["principal"].to_i) + + + @number_of_monthly_payments = @number_of_years*-12 + + @monthly_interest_percentage = @monthly_interest_basispoints/100 + + @monthly_interest = @monthly_interest_percentage/12 + + @monthly_payment = @principal*(@monthly_interest/(1-(1+@monthly_interest)**@number_of_monthly_payments)) + render("calculations/payment_form_template.html.erb") end def payment_results - interest_rate/years/present_value + # interest_rate/years/present_value + + @monthly_interest_basispoints = (params["interest_rate"].to_i) + @number_of_years = (params["years"].to_i) + @principal = (params["principal"].to_i) + - # @apr = params["interest_rate"].to_i - # @number_of_years = - # @principal = + @number_of_monthly_payments = @number_of_years*-12 + @monthly_interest_percentage = @monthly_interest_basispoints/100 - # monthly_interest = (@apr/12)/100 - # number_of_monthly_payments = @years*-12 + @monthly_interest = @monthly_interest_percentage/12 - # @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) + @monthly_payment = @principal*(@monthly_interest/(1-(1+@monthly_interest)**@number_of_monthly_payments)) render("calculations/payment_results_template.html.erb") end @@ -102,24 +134,46 @@ def payment_results def random_number_form + @random_number = params["random_number"].to_i + @random_number_output = rand(@maximum)-rand(@minimum) + render("calculations/random_number_form_template.html.erb") end def random_number_results - + @random_number = params["random_number"].to_i + @random_number_output = rand(@maximum)-rand(@minimum) render("calculations/random_number_results_template.html.erb") end - def word_count_form + def word_count_form + + @text = params[:user_text] + @special_word = params[:user_word] + + @word_count = @text.split(" ").length + + @character_count_with_spaces = @text.length + + @character_count_without_spaces = @text.length-@text.count(" ") + + punctuation = @text.chomp(".") + + downcased_words = punctuation.downcase.split(" ") + + downcased_special = @special_word.downcase + + @occurrences = downcased_words.count(downcased_special) + render("calculations/word_count_form_template.html.erb") end - def random_number_results + def word_count_results @@ -128,14 +182,70 @@ def random_number_results - def stats_form + def stats_form + + @stats_numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) + + @sorted_numbers = @numbers.sort + + @count = @numbers.count + + @minimum_stats = @numbers.min + + @maximum_stats = @numbers.max + + @range = @maximum-@minimum + + @median = @sorted_numbers[((@count/2)+(1/2))] + + @sum = @numbers.sum + + @mean = @sum/@count + + @demeaned=@numbers.map { |i| i - @mean} + @squared = @demeaned.map { |i| i**2} + @variance = @squared.sum / @count + + @variance = @squared.sum / @count + + @standard_deviation = Math.sqrt(@variance) + + @mode_count = @numbers.map { |i| @numbers.count(i)} + @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] render("calculations/stats_form_template.html.erb") end def stats_results - + @stats_numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) + + @sorted_numbers = @numbers.sort + + @count = @numbers.count + + @minimum_stats = @numbers.min + + @maximum_stats = @numbers.max + + @range = @maximum-@minimum + + @median = @sorted_numbers[((@count/2)+(1/2))] + + @sum = @numbers.sum + + @mean = @sum/@count + + @demeaned=@numbers.map { |i| i - @mean} + @squared = @demeaned.map { |i| i**2} + @variance = @squared.sum / @count + + @variance = @squared.sum / @count + + @standard_deviation = Math.sqrt(@variance) + + @mode_count = @numbers.map { |i| @numbers.count(i)} + @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] render("calculations/stats_results_template.html.erb") end diff --git a/app/views/calculations/flexible_payment_template.html.erb b/app/views/calculations/flexible_payment_template.html.erb index fd75b5a..94b99ca 100644 --- a/app/views/calculations/flexible_payment_template.html.erb +++ b/app/views/calculations/flexible_payment_template.html.erb @@ -1,3 +1,3 @@

Flexible Payment

-

A <%= @number_of_years %> year loan of <%= @principal %>, with an interest rate of is <%= @apr %>, requires a monthly payment of <%= @monthly_payment %>

\ No newline at end of file +

A <%= @number_of_years %> year loan of <%= @principal %>, with an interest rate of is <%= @monthly_interest_percentage %>, requires a monthly payment of <%= @monthly_payment %>

\ No newline at end of file diff --git a/app/views/calculations/flexible_random_number_template.html.erb b/app/views/calculations/flexible_random_number_template.html.erb index 07711a2..e69de29 100644 --- a/app/views/calculations/flexible_random_number_template.html.erb +++ b/app/views/calculations/flexible_random_number_template.html.erb @@ -1,3 +0,0 @@ -

Flexible Random Number

- -

A random number between <%= 50 %> and <%= 100 %>is <%= @random_number %>.

\ No newline at end of file diff --git a/app/views/calculations/flexible_square_root_template.html.erb b/app/views/calculations/flexible_square_root_template.html.erb index 85efe3b..de9bdf1 100644 --- a/app/views/calculations/flexible_square_root_template.html.erb +++ b/app/views/calculations/flexible_square_root_template.html.erb @@ -1,3 +1,3 @@

Flexible Square Root

-

The square root of <%= @user_number %> is <%= @squared_root %>.

\ No newline at end of file +

The square root of <%= @user_square_root_number_flex %> is <%= @square_root_flex %>.

\ No newline at end of file diff --git a/app/views/calculations/flexible_square_template.html.erb b/app/views/calculations/flexible_square_template.html.erb index 7c0c4ff..9945e97 100644 --- a/app/views/calculations/flexible_square_template.html.erb +++ b/app/views/calculations/flexible_square_template.html.erb @@ -1,6 +1,6 @@

Flexible Square

-

The square of <%= @user_number %> is <%= @squared_number %>.

+

The square of <%= @user_number_flex %> is <%= @squared_number_flex %>.

diff --git a/app/views/calculations/payment_results_template.html.erb b/app/views/calculations/payment_results_template.html.erb index b6ccc43..23ece02 100644 --- a/app/views/calculations/payment_results_template.html.erb +++ b/app/views/calculations/payment_results_template.html.erb @@ -4,32 +4,32 @@

APR

- - - +
+ @monthly_interest_percentage +

Number of years

- - - +
+ @number_of_years +

Principal

- - - +
+ @principal +

Payment

- - - +
+ @monthly_payment +
Calculate another payment \ No newline at end of file diff --git a/app/views/calculations/random_number_results_template.html.erb b/app/views/calculations/random_number_results_template.html.erb index e774d16..0bb4f8d 100644 --- a/app/views/calculations/random_number_results_template.html.erb +++ b/app/views/calculations/random_number_results_template.html.erb @@ -4,24 +4,24 @@

Minimum

- - - +
+ @minimum +

Maximum

- - - +
+ @maximum +

Random Number

- - - +
+ @random_number +
Pick another random number \ No newline at end of file diff --git a/app/views/calculations/square_results_template.html.erb b/app/views/calculations/square_results_template.html.erb index f3173c6..3687aa7 100644 --- a/app/views/calculations/square_results_template.html.erb +++ b/app/views/calculations/square_results_template.html.erb @@ -4,17 +4,17 @@

Number

- - - +
+ @user_number +

Square

- - - +
+ @squared_number +
Calculate another square \ No newline at end of file diff --git a/app/views/calculations/square_root_form_template.html.erb b/app/views/calculations/square_root_form_template.html.erb index 51a4fc5..8ee8442 100644 --- a/app/views/calculations/square_root_form_template.html.erb +++ b/app/views/calculations/square_root_form_template.html.erb @@ -13,5 +13,3 @@ - Go to Google - \ No newline at end of file diff --git a/app/views/calculations/square_root_results_template.html.erb b/app/views/calculations/square_root_results_template.html.erb index ebe07df..532e69c 100644 --- a/app/views/calculations/square_root_results_template.html.erb +++ b/app/views/calculations/square_root_results_template.html.erb @@ -4,17 +4,17 @@

Number

- - - +
+ @user_number_root +

Square Root

- - - +
+

@squared_r

+
Calculate another square root \ No newline at end of file diff --git a/app/views/calculations/stats_results_template.html.erb b/app/views/calculations/stats_results_template.html.erb index 03b6fb6..0196fc3 100644 --- a/app/views/calculations/stats_results_template.html.erb +++ b/app/views/calculations/stats_results_template.html.erb @@ -4,103 +4,103 @@

Numbers Entered

- - - +
+ @stats_numbers +

Sorted Numbers

- - - +
+ @sorted_numbers +

Count

- - - +
+ @count +

Minimum

- - - +
+ @minimum_stats +

Maximum

- - - +
+ @maximum_stats +

Range

- - - +
+ @range +

Median

- - - +
+ @median +

Sum

- - - +
+ @sum +

Mean

- - - +
+ @mean +

Variance

- - - +
+ @variance +

Standard Deviation

- - - +
+ @standard_deviation +

Mode

- - - +
+ @mode +
Calculate another Descriptive Stats \ No newline at end of file diff --git a/app/views/calculations/word_count_results_template.html.erb b/app/views/calculations/word_count_results_template.html.erb index 003a43f..a144ef1 100644 --- a/app/views/calculations/word_count_results_template.html.erb +++ b/app/views/calculations/word_count_results_template.html.erb @@ -4,40 +4,40 @@

Text

- - - +
+ @text +

Word Count

- - - +
+ @word_count +

Character Count (with spaces)

- - - +
+ @character_count_with_spaces +

Character Count (without spaces)

- - - +
+ @character_count_without_spaces +

Occurances of @special_word

- - - +
+ @occurrences = downcased_words.count(downcased_special) +
Process more text \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index dd45a65..4f23c92 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,28 +1,26 @@ Rails.application.routes.draw do - get("/flexible/square/:a_number", { :controller => "calculations", :action => "flex_square" }) + get("/flexible/square/:a_number_flex", { :controller => "calculations", :action => "flex_square" }) - get("/flexible/square_root/:a_number", { :controller => "calculations", :action => "flex_square_root" }) + get("/flexible/square_root/:square_root_number_flex", { :controller => "calculations", :action => "flex_square_root" }) - get("/flexible/payment/:interest_rate/:years/:principal/", { :controller => "calculations", :action => "flex_payment" }) + get("/flexible/payment/:interest_rate_flex/:years_flex/:principal_flex/", { :controller => "calculations", :action => "flex_payment" }) - get("/flexible/random/:@random_number", { :controller => "calculations", :action => "flex_random_number" }) + get("/flexible/random/:random_number_flex", { :controller => "calculations", :action => "flex_random_number" }) - get("/square/new", { :controller => "calculations", :action => "square_form" }) + get("/square/:a_number", { :controller => "calculations", :action => "square_form" }) - get("/square/results", { :controller => "calculations", :action => "square_root_form" }) + get("/square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form" }) - get("/payment/interest_rate/years/present_value", { :controller => "calculations", :action => "payment_form" }) + get("/payment/:interest_rate/:years/:principal", { :controller => "calculations", :action => "payment_form"}) - get("/random/results", { :controller => "calculations", :action => "random_number_form" }) + get("/random/:random_number", {:controller => "calculations", :action => "random_number_form"}) + get("/word_count/", {:controller => "calculations", :action => "word_count_form"}) - - get("/word_count/results", { :controller => "calculations", :action => "word_count_form" }) - - get("/descriptive_stats/results", { :controller => "calculations", :action => "stats_form" }) + get("/descriptive_stats", {:controller => "calculations", :action => "stats_form"}) From 18a6e5aa09723d043c31fd691ad5e639b4e1acda Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 17:18:31 +0000 Subject: [PATCH 08/46] random section updated --- app/controllers/calculations_controller.rb | 6 +++--- public/homepage.html | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 public/homepage.html diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 9ce4178..fda293b 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -41,7 +41,7 @@ def flex_payment def flex_random_number @random_number_flex = params["random_number_flex"].to_i - @random_number_output_flex = rand(100)-rand(50) + @random_number_output_flex = rand(50...100) # random number between 50 & 100 @@ -135,7 +135,7 @@ def payment_results def random_number_form @random_number = params["random_number"].to_i - @random_number_output = rand(@maximum)-rand(@minimum) + @random_number_output = rand(@minimum...@maximum) render("calculations/random_number_form_template.html.erb") end @@ -143,7 +143,7 @@ def random_number_form def random_number_results @random_number = params["random_number"].to_i - @random_number_output = rand(@maximum)-rand(@minimum) + @random_number_output = rand(@minimum...@maximum) render("calculations/random_number_results_template.html.erb") end diff --git a/public/homepage.html b/public/homepage.html new file mode 100644 index 0000000..36b1fbd --- /dev/null +++ b/public/homepage.html @@ -0,0 +1,15 @@ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ From d44e76cd191f33adcd653f6b6fca94aa061916fd Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 20:20:38 +0000 Subject: [PATCH 09/46] homepage --- app/controllers/homepage_controller.rb | 84 +++++++++++++++++++ .../flexible_random_number_template.html.erb | 3 + .../calculations/homepage_template.html.erb | 69 +++++++++++++++ config/routes.rb | 4 + public/homepage.html | 15 ---- 5 files changed, 160 insertions(+), 15 deletions(-) create mode 100644 app/controllers/homepage_controller.rb create mode 100644 app/views/calculations/homepage_template.html.erb delete mode 100644 public/homepage.html diff --git a/app/controllers/homepage_controller.rb b/app/controllers/homepage_controller.rb new file mode 100644 index 0000000..42c863a --- /dev/null +++ b/app/controllers/homepage_controller.rb @@ -0,0 +1,84 @@ +class HomepageController < ApplicationController + def homepage + + + div class="container"> + +
+
+ Part II Targets +
+ + + + + + + + + + +
+
+
+ Part III Targets +
+ + + + + + +
+
+
+ + +
+
+ + + + + + + + + render("calculations/homepage_template.html.erb") + end + + +end \ No newline at end of file diff --git a/app/views/calculations/flexible_random_number_template.html.erb b/app/views/calculations/flexible_random_number_template.html.erb index e69de29..258ff20 100644 --- a/app/views/calculations/flexible_random_number_template.html.erb +++ b/app/views/calculations/flexible_random_number_template.html.erb @@ -0,0 +1,3 @@ +

Flexible Random Number

+ +

A random number between 50 and 100 is <%= @random_number_flex %>.

\ No newline at end of file diff --git a/app/views/calculations/homepage_template.html.erb b/app/views/calculations/homepage_template.html.erb new file mode 100644 index 0000000..30b85da --- /dev/null +++ b/app/views/calculations/homepage_template.html.erb @@ -0,0 +1,69 @@ +
+ +
+
+ Part II Targets +
+ + + + + + + + + + +
+
+
+ Part III Targets +
+ + + + + + +
+
+
+ + +
+
+
+ diff --git a/config/routes.rb b/config/routes.rb index 4f23c92..0909a45 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ Rails.application.routes.draw do + get("/", { :controller => "homepage", :action => "homepage" }) + + + get("/flexible/square/:a_number_flex", { :controller => "calculations", :action => "flex_square" }) get("/flexible/square_root/:square_root_number_flex", { :controller => "calculations", :action => "flex_square_root" }) diff --git a/public/homepage.html b/public/homepage.html deleted file mode 100644 index 36b1fbd..0000000 --- a/public/homepage.html +++ /dev/null @@ -1,15 +0,0 @@ -
-
-
-
-
-
-
-
-
-
-
-
-
-
- From 9a14c02cb5940d5dbeec6010ae8295471b2e32da Mon Sep 17 00:00:00 2001 From: Em Klick Date: Mon, 17 Jul 2017 20:49:39 +0000 Subject: [PATCH 10/46] connections --- public/omnicalc_params_homepage.html | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 public/omnicalc_params_homepage.html diff --git a/public/omnicalc_params_homepage.html b/public/omnicalc_params_homepage.html new file mode 100644 index 0000000..2709a12 --- /dev/null +++ b/public/omnicalc_params_homepage.html @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Part I Targets

+
+ Flexible Square Example + + Flexible Square Example + + Flexible Square Example + + Flexible Square Example +
+

Part II Targets

+
+ Square Form + + Square Root Form + + Payment Form + + Random Number Form +
+

Part III Targets

+
+ Word Count Form + + Stats Form + + + + +
+

The function goes here

+
+ + From ad031a87853147c8fd0ca3bf580be21c46e6894b Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 00:44:21 +0000 Subject: [PATCH 11/46] qwerty --- .../payment_results_template.html.erb | 8 +++---- .../random_number_results_template.html.erb | 6 ++--- .../square_results_template.html.erb | 4 ++-- .../square_root_results_template.html.erb | 4 ++-- .../stats_results_template.html.erb | 24 +++++++++---------- .../word_count_results_template.html.erb | 12 +++++----- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/app/views/calculations/payment_results_template.html.erb b/app/views/calculations/payment_results_template.html.erb index 23ece02..84ae7d8 100644 --- a/app/views/calculations/payment_results_template.html.erb +++ b/app/views/calculations/payment_results_template.html.erb @@ -5,7 +5,7 @@
- @monthly_interest_percentage + <%= @monthly_interest_percentage %>
@@ -13,7 +13,7 @@
- @number_of_years + <%= @number_of_years %>
@@ -21,7 +21,7 @@
- @principal + <%= @principal %>
@@ -29,7 +29,7 @@
- @monthly_payment + <%= @monthly_payment%>
Calculate another payment \ No newline at end of file diff --git a/app/views/calculations/random_number_results_template.html.erb b/app/views/calculations/random_number_results_template.html.erb index 0bb4f8d..a2a6cdd 100644 --- a/app/views/calculations/random_number_results_template.html.erb +++ b/app/views/calculations/random_number_results_template.html.erb @@ -5,7 +5,7 @@
- @minimum + <%= @minimum %>
@@ -13,7 +13,7 @@
- @maximum + <%= @maximum %>
@@ -21,7 +21,7 @@
- @random_number + <%= @random_number %>
Pick another random number \ No newline at end of file diff --git a/app/views/calculations/square_results_template.html.erb b/app/views/calculations/square_results_template.html.erb index 3687aa7..2e60502 100644 --- a/app/views/calculations/square_results_template.html.erb +++ b/app/views/calculations/square_results_template.html.erb @@ -5,7 +5,7 @@
- @user_number + <%= @user_number %>
@@ -13,7 +13,7 @@
- @squared_number + <%= @squared_number %>
diff --git a/app/views/calculations/square_root_results_template.html.erb b/app/views/calculations/square_root_results_template.html.erb index 532e69c..8a6dba4 100644 --- a/app/views/calculations/square_root_results_template.html.erb +++ b/app/views/calculations/square_root_results_template.html.erb @@ -5,7 +5,7 @@
- @user_number_root + <%= @user_number_root %>
@@ -13,7 +13,7 @@
-

@squared_r

+ <%= @squared_root %
diff --git a/app/views/calculations/stats_results_template.html.erb b/app/views/calculations/stats_results_template.html.erb index 0196fc3..7fc8ff2 100644 --- a/app/views/calculations/stats_results_template.html.erb +++ b/app/views/calculations/stats_results_template.html.erb @@ -5,7 +5,7 @@
- @stats_numbers + <%= @stats_numbers %>
@@ -14,7 +14,7 @@
- @sorted_numbers + <%= @sorted_numbers %>
@@ -23,7 +23,7 @@
- @count + <%= @count %>
@@ -32,7 +32,7 @@
- @minimum_stats + <%= @minimum_stats %>
@@ -40,7 +40,7 @@
- @maximum_stats + <%= @maximum_stats %>
@@ -49,7 +49,7 @@
- @range + <%= @range %>
@@ -58,7 +58,7 @@
- @median + <%= @median %>
@@ -67,7 +67,7 @@
- @sum + <%= @sum %>
@@ -75,7 +75,7 @@
- @mean + <%= @mean %>
@@ -83,7 +83,7 @@
- @variance + <%= @variance %>
@@ -91,7 +91,7 @@
- @standard_deviation + <%= @standard_deviation %>
@@ -99,7 +99,7 @@
- @mode + <%= @mode %>
diff --git a/app/views/calculations/word_count_results_template.html.erb b/app/views/calculations/word_count_results_template.html.erb index a144ef1..bc89665 100644 --- a/app/views/calculations/word_count_results_template.html.erb +++ b/app/views/calculations/word_count_results_template.html.erb @@ -5,7 +5,7 @@
- @text + <%= @text %>
@@ -13,7 +13,7 @@
- @word_count + <%= @word_count %>
@@ -21,7 +21,7 @@
- @character_count_with_spaces + <%= @character_count_with_spaces %>
@@ -29,15 +29,15 @@
- @character_count_without_spaces + <%= @character_count_without_spaces %>
-

Occurances of @special_word

+

Occurances of <%= @special_word %>

- @occurrences = downcased_words.count(downcased_special) + <%= @occurrences %>
Process more text \ No newline at end of file From 2eb9375c4f5e049f0808481f63d270636f46474f Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 00:51:15 +0000 Subject: [PATCH 12/46] qwertyy --- app/controllers/calculations_controller.rb | 93 +--------------------- 1 file changed, 2 insertions(+), 91 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index fda293b..e320d83 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -62,33 +62,15 @@ def square_form render("calculations/square_form_template.html.erb") end - def square_results - - @user_number_root = params["a_number"].to_i - @squared_number = @user_number_root**2 - - render("calculations/square_results_template.html.erb") - end - - def square_root_form - @user_number_root = params["square_root_number"].to_i + @user_number_square_root = params["square_root_number"].to_i @squared_root = Math.sqrt(@user_number_root) render("calculations/square_form_template.html.erb") end - - def square_root_results - - @user_number_root = params["square_root_number"].to_i - @squared_root = Math.sqrt(@user_number_root) - - render("calculations/square_results_template.html.erb") - end - - + def payment_form @@ -110,27 +92,6 @@ def payment_form render("calculations/payment_form_template.html.erb") end - def payment_results - - # interest_rate/years/present_value - - @monthly_interest_basispoints = (params["interest_rate"].to_i) - @number_of_years = (params["years"].to_i) - @principal = (params["principal"].to_i) - - - @number_of_monthly_payments = @number_of_years*-12 - - @monthly_interest_percentage = @monthly_interest_basispoints/100 - - @monthly_interest = @monthly_interest_percentage/12 - - @monthly_payment = @principal*(@monthly_interest/(1-(1+@monthly_interest)**@number_of_monthly_payments)) - - render("calculations/payment_results_template.html.erb") - end - - def random_number_form @@ -140,15 +101,6 @@ def random_number_form render("calculations/random_number_form_template.html.erb") end - def random_number_results - - @random_number = params["random_number"].to_i - @random_number_output = rand(@minimum...@maximum) - - render("calculations/random_number_results_template.html.erb") - end - - def word_count_form @@ -173,14 +125,6 @@ def word_count_form render("calculations/word_count_form_template.html.erb") end - def word_count_results - - - - render("calculations/word_count_results_template.html.erb") - end - - def stats_form @@ -216,39 +160,6 @@ def stats_form render("calculations/stats_form_template.html.erb") end - def stats_results - - @stats_numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) - - @sorted_numbers = @numbers.sort - - @count = @numbers.count - - @minimum_stats = @numbers.min - - @maximum_stats = @numbers.max - - @range = @maximum-@minimum - - @median = @sorted_numbers[((@count/2)+(1/2))] - - @sum = @numbers.sum - - @mean = @sum/@count - - @demeaned=@numbers.map { |i| i - @mean} - @squared = @demeaned.map { |i| i**2} - @variance = @squared.sum / @count - - @variance = @squared.sum / @count - - @standard_deviation = Math.sqrt(@variance) - - @mode_count = @numbers.map { |i| @numbers.count(i)} - @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] - - render("calculations/stats_results_template.html.erb") - end end From 9d207c23605be63b925ebe729bdf1ea08947dcea Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 01:41:44 +0000 Subject: [PATCH 13/46] testing --- app/controllers/calculations_controller.rb | 12 ++++++------ config/routes.rb | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index e320d83..485990a 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -21,9 +21,9 @@ def flex_square_root def flex_payment - @monthly_interest_basispoints_flex = (params["interest_rate_flex"].to_i) - @number_of_years_flex = (params["years_flex"].to_i) - @principal_flex = (params["principal_flex"].to_i) + @monthly_interest_basispoints_flex = params["interest_rate_flex"].to_i + @number_of_years_flex = params["years_flex"].to_i + @principal_flex = params["principal_flex"].to_i @number_of_monthly_payments_flex = @number_of_years_flex*-12 @@ -76,9 +76,9 @@ def payment_form # interest_rate/years/present_value - @monthly_interest_basispoints = (params["interest_rate"].to_i) - @number_of_years = (params["years"].to_i) - @principal = (params["principal"].to_i) + @monthly_interest_basispoints = params["interest_rate"].to_i + @number_of_years = params["years"].to_i + @principal = params["principal"].to_i @number_of_monthly_payments = @number_of_years*-12 diff --git a/config/routes.rb b/config/routes.rb index 0909a45..34794a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Rails.application.routes.draw do - get("/", { :controller => "homepage", :action => "homepage" }) + # get("/", { :controller => "homepage", :action => "homepage" }) @@ -22,9 +22,9 @@ get("/random/:random_number", {:controller => "calculations", :action => "random_number_form"}) - get("/word_count/", {:controller => "calculations", :action => "word_count_form"}) + get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) - get("/descriptive_stats", {:controller => "calculations", :action => "stats_form"}) + get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) From 71c9b62e51a76597a7e6d5a117b4fb4654589ab1 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 01:46:04 +0000 Subject: [PATCH 14/46] square root calculation --- app/controllers/calculations_controller.rb | 152 +++++++++--------- .../flexible_square_root_template.html.erb | 2 +- config/routes.rb | 20 +-- 3 files changed, 88 insertions(+), 86 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 485990a..cdbdff9 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -12,41 +12,41 @@ def flex_square def flex_square_root - @user_square_root_number_flex = params["square_root_number_flex"].to_i - @square_root_flex = Math.sqrt(@user_square_root_number_flex) + @user_square_root_flex = params["a_number_flex"].to_i + @square_root_flex = Math.sqrt(@user_square_root_flex) - render("calculations/flexible_square_template.html.erb") + render("calculations/flexible_square_root_template.html.erb") end - def flex_payment + # def flex_payment - @monthly_interest_basispoints_flex = params["interest_rate_flex"].to_i - @number_of_years_flex = params["years_flex"].to_i - @principal_flex = params["principal_flex"].to_i + # @monthly_interest_basispoints_flex = params["interest_rate_flex"].to_i + # @number_of_years_flex = params["years_flex"].to_i + # @principal_flex = params["principal_flex"].to_i - @number_of_monthly_payments_flex = @number_of_years_flex*-12 + # @number_of_monthly_payments_flex = @number_of_years_flex*-12 - @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/100 + # @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/100 - @monthly_interest_flex = @monthly_interest_percentage_flex/12 + # @monthly_interest_flex = @monthly_interest_percentage_flex/12 - @monthly_payment_flex = @principal_flex*(@monthly_interest_flex/(1-(1+@monthly_interest_flex)**@number_of_monthly_payments_flex)) + # @monthly_payment_flex = @principal_flex*(@monthly_interest_flex/(1-(1+@monthly_interest_flex)**@number_of_monthly_payments_flex)) - render("calculations/flexible_payment_template.html.erb") - end + # render("calculations/flexible_payment_template.html.erb") + # end - def flex_random_number + # def flex_random_number - @random_number_flex = params["random_number_flex"].to_i - @random_number_output_flex = rand(50...100) + # @random_number_flex = params["random_number_flex"].to_i + # @random_number_output_flex = rand(50...100) - # random number between 50 & 100 + # # random number between 50 & 100 - render("calculations/flexible_random_number_template.html.erb") - end + # render("calculations/flexible_random_number_template.html.erb") + # end @@ -54,111 +54,111 @@ def flex_random_number - def square_form + # def square_form - @user_number = params["a_number"].to_i - @squared_number = @user_number**2 + # @user_number = params["a_number"].to_i + # @squared_number = @user_number**2 - render("calculations/square_form_template.html.erb") - end + # render("calculations/square_form_template.html.erb") + # end - def square_root_form + # def square_root_form - @user_number_square_root = params["square_root_number"].to_i - @squared_root = Math.sqrt(@user_number_root) + # @user_number_square_root = params["square_root_number"].to_i + # @squared_root = Math.sqrt(@user_number_root) - render("calculations/square_form_template.html.erb") - end + # render("calculations/square_form_template.html.erb") + # end - def payment_form + # def payment_form - # interest_rate/years/present_value + # # interest_rate/years/present_value - @monthly_interest_basispoints = params["interest_rate"].to_i - @number_of_years = params["years"].to_i - @principal = params["principal"].to_i + # @monthly_interest_basispoints = params["interest_rate"].to_i + # @number_of_years = params["years"].to_i + # @principal = params["principal"].to_i - @number_of_monthly_payments = @number_of_years*-12 + # @number_of_monthly_payments = @number_of_years*-12 - @monthly_interest_percentage = @monthly_interest_basispoints/100 + # @monthly_interest_percentage = @monthly_interest_basispoints/100 - @monthly_interest = @monthly_interest_percentage/12 + # @monthly_interest = @monthly_interest_percentage/12 - @monthly_payment = @principal*(@monthly_interest/(1-(1+@monthly_interest)**@number_of_monthly_payments)) + # @monthly_payment = @principal*(@monthly_interest/(1-(1+@monthly_interest)**@number_of_monthly_payments)) - render("calculations/payment_form_template.html.erb") - end + # render("calculations/payment_form_template.html.erb") + # end - def random_number_form + # def random_number_form - @random_number = params["random_number"].to_i - @random_number_output = rand(@minimum...@maximum) + # @random_number = params["random_number"].to_i + # @random_number_output = rand(@minimum...@maximum) - render("calculations/random_number_form_template.html.erb") - end + # render("calculations/random_number_form_template.html.erb") + # end - def word_count_form + # def word_count_form - @text = params[:user_text] - @special_word = params[:user_word] + # @text = params[:user_text] + # @special_word = params[:user_word] - @word_count = @text.split(" ").length + # @word_count = @text.split(" ").length - @character_count_with_spaces = @text.length + # @character_count_with_spaces = @text.length - @character_count_without_spaces = @text.length-@text.count(" ") + # @character_count_without_spaces = @text.length-@text.count(" ") - punctuation = @text.chomp(".") + # punctuation = @text.chomp(".") - downcased_words = punctuation.downcase.split(" ") + # downcased_words = punctuation.downcase.split(" ") - downcased_special = @special_word.downcase + # downcased_special = @special_word.downcase - @occurrences = downcased_words.count(downcased_special) + # @occurrences = downcased_words.count(downcased_special) - render("calculations/word_count_form_template.html.erb") - end + # render("calculations/word_count_form_template.html.erb") + # end - def stats_form + # def stats_form - @stats_numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) + # @stats_numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) - @sorted_numbers = @numbers.sort + # @sorted_numbers = @numbers.sort - @count = @numbers.count + # @count = @numbers.count - @minimum_stats = @numbers.min + # @minimum_stats = @numbers.min - @maximum_stats = @numbers.max + # @maximum_stats = @numbers.max - @range = @maximum-@minimum + # @range = @maximum-@minimum - @median = @sorted_numbers[((@count/2)+(1/2))] + # @median = @sorted_numbers[((@count/2)+(1/2))] - @sum = @numbers.sum + # @sum = @numbers.sum - @mean = @sum/@count + # @mean = @sum/@count - @demeaned=@numbers.map { |i| i - @mean} - @squared = @demeaned.map { |i| i**2} - @variance = @squared.sum / @count + # @demeaned=@numbers.map { |i| i - @mean} + # @squared = @demeaned.map { |i| i**2} + # @variance = @squared.sum / @count - @variance = @squared.sum / @count + # @variance = @squared.sum / @count - @standard_deviation = Math.sqrt(@variance) + # @standard_deviation = Math.sqrt(@variance) - @mode_count = @numbers.map { |i| @numbers.count(i)} - @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] + # @mode_count = @numbers.map { |i| @numbers.count(i)} + # @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] - render("calculations/stats_form_template.html.erb") - end + # render("calculations/stats_form_template.html.erb") + # end diff --git a/app/views/calculations/flexible_square_root_template.html.erb b/app/views/calculations/flexible_square_root_template.html.erb index de9bdf1..356851c 100644 --- a/app/views/calculations/flexible_square_root_template.html.erb +++ b/app/views/calculations/flexible_square_root_template.html.erb @@ -1,3 +1,3 @@

Flexible Square Root

-

The square root of <%= @user_square_root_number_flex %> is <%= @square_root_flex %>.

\ No newline at end of file +

The square root of <%= @user_square_root_flex %> is <%= @square_root_flex %>.

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 34794a5..49ea787 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,25 +6,27 @@ get("/flexible/square/:a_number_flex", { :controller => "calculations", :action => "flex_square" }) - get("/flexible/square_root/:square_root_number_flex", { :controller => "calculations", :action => "flex_square_root" }) + get("/flexible/square_root/:a_number_flex", { :controller => "calculations", :action => "flex_square_root"}) - get("/flexible/payment/:interest_rate_flex/:years_flex/:principal_flex/", { :controller => "calculations", :action => "flex_payment" }) + # get("/flexible/square_root/:square_root_number_flex", { :controller => "calculations", :action => "flex_square_root" }) - get("/flexible/random/:random_number_flex", { :controller => "calculations", :action => "flex_random_number" }) + # get("/flexible/payment/:interest_rate_flex/:years_flex/:principal_flex/", { :controller => "calculations", :action => "flex_payment" }) + # get("/flexible/random/:random_number_flex", { :controller => "calculations", :action => "flex_random_number" }) - get("/square/:a_number", { :controller => "calculations", :action => "square_form" }) - get("/square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form" }) + # get("/square/:a_number", { :controller => "calculations", :action => "square_form" }) - get("/payment/:interest_rate/:years/:principal", { :controller => "calculations", :action => "payment_form"}) + # get("/square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form" }) - get("/random/:random_number", {:controller => "calculations", :action => "random_number_form"}) + # get("/payment/:interest_rate/:years/:principal", { :controller => "calculations", :action => "payment_form"}) - get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) + # get("/random/:random_number", {:controller => "calculations", :action => "random_number_form"}) - get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) + # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) + + # get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) From 27751eb9b727ddc9e1cc7164a018b33387bf7bea Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 03:21:43 +0000 Subject: [PATCH 15/46] payment --- app/controllers/calculations_controller.rb | 36 +++++++++++++------ .../flexible_payment_template.html.erb | 2 +- config/routes.rb | 4 +-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index cdbdff9..24e127f 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -19,23 +19,39 @@ def flex_square_root end - # def flex_payment + def flex_payment - # @monthly_interest_basispoints_flex = params["interest_rate_flex"].to_i - # @number_of_years_flex = params["years_flex"].to_i - # @principal_flex = params["principal_flex"].to_i + @monthly_interest_basispoints_flex = params["basis_points"].to_i + @number_of_years_flex = params["number_of_years"].to_i + @present_value_flex = params["present_value"].to_i + @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex*10000 + monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 - # @number_of_monthly_payments_flex = @number_of_years_flex*-12 + @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> + + + + # number_of_monthly_payments_flex = @number_of_years*-12 + + # one_plus_rate_per_period = @monthly_interest_per_period_flex - # @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/100 + @monthly_payment_flex = (monthly_interest_per_period_flex*@present_value_flex) - # @monthly_interest_flex = @monthly_interest_percentage_flex/12 + # /(1-((one_plus_rate_per_period)**(number_of_monthly_payments_flex)) + + # monthly_interest = (@apr/12)/100 + # number_of_monthly_payments = @years*-12 - # @monthly_payment_flex = @principal_flex*(@monthly_interest_flex/(1-(1+@monthly_interest_flex)**@number_of_monthly_payments_flex)) + # @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) - # render("calculations/flexible_payment_template.html.erb") - # end + + + + + + render("calculations/flexible_payment_template.html.erb") + end # def flex_random_number diff --git a/app/views/calculations/flexible_payment_template.html.erb b/app/views/calculations/flexible_payment_template.html.erb index 94b99ca..fba4bed 100644 --- a/app/views/calculations/flexible_payment_template.html.erb +++ b/app/views/calculations/flexible_payment_template.html.erb @@ -1,3 +1,3 @@

Flexible Payment

-

A <%= @number_of_years %> year loan of <%= @principal %>, with an interest rate of is <%= @monthly_interest_percentage %>, requires a monthly payment of <%= @monthly_payment %>

\ No newline at end of file +

A <%= @number_of_years_flex %> year loan of <%= @present_value_flex %>, with an interest rate of is <%= @monthly_interest_percentage_flex %>%, requires a monthly payment of <%= @monthly_payment_flex %>

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 49ea787..65ce210 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,9 +8,9 @@ get("/flexible/square_root/:a_number_flex", { :controller => "calculations", :action => "flex_square_root"}) - # get("/flexible/square_root/:square_root_number_flex", { :controller => "calculations", :action => "flex_square_root" }) + get("/flexible/payment/:basis_points/:number_of_years/:present_value", {:controller => "calculations", :action => "flex_payment"}) - # get("/flexible/payment/:interest_rate_flex/:years_flex/:principal_flex/", { :controller => "calculations", :action => "flex_payment" }) + # get("/flexible/payment/:basis_points/:number_of_years/:present_value", { :controller => "calculations", :action => "flex_payment" }) # get("/flexible/random/:random_number_flex", { :controller => "calculations", :action => "flex_random_number" }) From 683e744d6db1394c3c01a5ad897020f22bbd9543 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 03:36:11 +0000 Subject: [PATCH 16/46] square --- app/controllers/calculations_controller.rb | 47 ++++++++----------- .../flexible_random_number_template.html.erb | 2 +- config/routes.rb | 4 +- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 24e127f..316835e 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -26,43 +26,36 @@ def flex_payment @present_value_flex = params["present_value"].to_i @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex*10000 - monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 + @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 - @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> +# @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> - + # <%= number_to_currency(@number_of_years_flex) %> # number_of_monthly_payments_flex = @number_of_years*-12 - # one_plus_rate_per_period = @monthly_interest_per_period_flex - - @monthly_payment_flex = (monthly_interest_per_period_flex*@present_value_flex) - - # /(1-((one_plus_rate_per_period)**(number_of_monthly_payments_flex)) - - # monthly_interest = (@apr/12)/100 - # number_of_monthly_payments = @years*-12 - - # @monthly_payment = @principal*(monthly_interest/(1-(1+monthly_interest)**number_of_monthly_payments)) - - - + @one_plus_rate_per_period = (1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex + @denomonator_step_one = 1 - @one_plus_rate_per_period + # + @numerator = (@monthly_interest_per_period_flex*@present_value_flex) + @denomonator = @denomonator_step_one + @monthly_payment_flex = @numerator/@denomonator render("calculations/flexible_payment_template.html.erb") end - # def flex_random_number + def flex_random_number - # @random_number_flex = params["random_number_flex"].to_i - # @random_number_output_flex = rand(50...100) + @random_number_flex = params["random_number_flex"].to_i + @random_number_output_flex = rand(50...100) - # # random number between 50 & 100 + # random number between 50 & 100 - # render("calculations/flexible_random_number_template.html.erb") - # end + render("calculations/flexible_random_number_template.html.erb") + end @@ -70,13 +63,13 @@ def flex_payment - # def square_form + def square_form - # @user_number = params["a_number"].to_i - # @squared_number = @user_number**2 + @user_number = params["user_number"].to_i + @squared_number = @user_number**2 - # render("calculations/square_form_template.html.erb") - # end + render("calculations/square_form_template.html.erb") + end # def square_root_form diff --git a/app/views/calculations/flexible_random_number_template.html.erb b/app/views/calculations/flexible_random_number_template.html.erb index 258ff20..e4fbfbd 100644 --- a/app/views/calculations/flexible_random_number_template.html.erb +++ b/app/views/calculations/flexible_random_number_template.html.erb @@ -1,3 +1,3 @@

Flexible Random Number

-

A random number between 50 and 100 is <%= @random_number_flex %>.

\ No newline at end of file +

A random number between 50 and 100 is <%= @random_number_output_flex %>.

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 65ce210..fa22c32 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,10 +10,10 @@ get("/flexible/payment/:basis_points/:number_of_years/:present_value", {:controller => "calculations", :action => "flex_payment"}) - # get("/flexible/payment/:basis_points/:number_of_years/:present_value", { :controller => "calculations", :action => "flex_payment" }) + get("/flexible/random/:random_number_flex", {:controller => "calculations", :action => "flex_random_number" }) - # get("/flexible/random/:random_number_flex", { :controller => "calculations", :action => "flex_random_number" }) + get("/square/:user_number", { :controller => "calculations", :action => "square_form"}) # get("/square/:a_number", { :controller => "calculations", :action => "square_form" }) From ec8ced6b2370636c51dbaf93319c58cbea369794 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 03:47:01 +0000 Subject: [PATCH 17/46] random number - getting there --- app/controllers/calculations_controller.rb | 53 +++++++++++-------- .../random_number_results_template.html.erb | 2 +- config/routes.rb | 7 ++- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 316835e..2620c93 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -72,43 +72,52 @@ def square_form end - # def square_root_form + def square_root_form - # @user_number_square_root = params["square_root_number"].to_i - # @squared_root = Math.sqrt(@user_number_root) + @user_number_square_root = params["square_root_number"].to_i + @squared_root = Math.sqrt(@user_number_square_root) - # render("calculations/square_form_template.html.erb") - # end + render("calculations/square_form_template.html.erb") + end - # def payment_form + def payment_form + + @monthly_interest_basispoints_flex = params["basis_points"].to_i + @number_of_years_flex = params["number_of_years"].to_i + @present_value_flex = params["present_value"].to_i + + @monthly_interest_percentage_flex = (@monthly_interest_basispoints_flex*10000).to_i + @monthly_interest_per_period_flex = (@monthly_interest_percentage_flex/12).to_i + +# @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> + + # <%= number_to_currency(@number_of_years_flex) %> - # # interest_rate/years/present_value + # number_of_monthly_payments_flex = @number_of_years*-12 - # @monthly_interest_basispoints = params["interest_rate"].to_i - # @number_of_years = params["years"].to_i - # @principal = params["principal"].to_i + @one_plus_rate_per_period = ((1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex).to_i + @numerator = (@monthly_interest_per_period_flex*@present_value_flex).to_i - # @number_of_monthly_payments = @number_of_years*-12 + @denomonator_step_one = (1 - @one_plus_rate_per_period).to_i - # @monthly_interest_percentage = @monthly_interest_basispoints/100 + @denomonator = @denomonator_step_one - # @monthly_interest = @monthly_interest_percentage/12 - - # @monthly_payment = @principal*(@monthly_interest/(1-(1+@monthly_interest)**@number_of_monthly_payments)) + @monthly_payment_flex = @numerator/@denomonator - # render("calculations/payment_form_template.html.erb") - # end + render("calculations/payment_form_template.html.erb") + end - # def random_number_form + def random_number_form - # @random_number = params["random_number"].to_i - # @random_number_output = rand(@minimum...@maximum) + @minimum = params["min"].to_i + @maximum = params["max"].to_i + @random_number_output = rand(@minimum...@maximum) - # render("calculations/random_number_form_template.html.erb") - # end + render("calculations/random_number_form_template.html.erb") + end # def word_count_form diff --git a/app/views/calculations/random_number_results_template.html.erb b/app/views/calculations/random_number_results_template.html.erb index a2a6cdd..cfa891f 100644 --- a/app/views/calculations/random_number_results_template.html.erb +++ b/app/views/calculations/random_number_results_template.html.erb @@ -21,7 +21,7 @@
- <%= @random_number %> + <%= @random_number_output %>
Pick another random number \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fa22c32..6a3211e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,14 +15,13 @@ get("/square/:user_number", { :controller => "calculations", :action => "square_form"}) + get("square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form"}) - # get("/square/:a_number", { :controller => "calculations", :action => "square_form" }) + get("/payment/:basis_points/:number_of_years/:present_value", { :controller => "calculations", :action => "payment_form"}) - # get("/square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form" }) + get("random/:min/:max", { :controller => "calculations", :action => "random_number_form"}) - # get("/payment/:interest_rate/:years/:principal", { :controller => "calculations", :action => "payment_form"}) - # get("/random/:random_number", {:controller => "calculations", :action => "random_number_form"}) # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) From 0f18ecba4e1828d69a98d346236193ce7a7de077 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 03:52:19 +0000 Subject: [PATCH 18/46] word_count --- app/controllers/calculations_controller.rb | 24 +++++++++++----------- config/routes.rb | 6 ++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 2620c93..d396888 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -120,28 +120,28 @@ def random_number_form end - # def word_count_form + def word_count_form - # @text = params[:user_text] - # @special_word = params[:user_word] + @text = params[:user_text] + @special_word = params[:special_word] - # @word_count = @text.split(" ").length + @word_count = @text.split(" ").length - # @character_count_with_spaces = @text.length + @character_count_with_spaces = @text.length - # @character_count_without_spaces = @text.length-@text.count(" ") + @character_count_without_spaces = @text.length-@text.count(" ") - # punctuation = @text.chomp(".") + punctuation = @text.chomp(".") - # downcased_words = punctuation.downcase.split(" ") + downcased_words = punctuation.downcase.split(" ") - # downcased_special = @special_word.downcase + downcased_special = @special_word.downcase - # @occurrences = downcased_words.count(downcased_special) + @occurrences = downcased_words.count(downcased_special) - # render("calculations/word_count_form_template.html.erb") - # end + render("calculations/word_count_form_template.html.erb") + end # def stats_form diff --git a/config/routes.rb b/config/routes.rb index 6a3211e..e47ca25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,11 +21,9 @@ get("random/:min/:max", { :controller => "calculations", :action => "random_number_form"}) + get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) - - # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) - - # get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) + get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) From 618064a27031770be5f22b205aa8ca49808816f5 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 03:54:43 +0000 Subject: [PATCH 19/46] descriptive stats --- app/controllers/calculations_controller.rb | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index d396888..5f3cb30 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -144,39 +144,39 @@ def word_count_form end - # def stats_form + def stats_form - # @stats_numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) + @numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) - # @sorted_numbers = @numbers.sort + @sorted_numbers = @numbers.sort - # @count = @numbers.count + @count = @numbers.count - # @minimum_stats = @numbers.min + @minimum_stats = @numbers.min - # @maximum_stats = @numbers.max + @maximum_stats = @numbers.max - # @range = @maximum-@minimum + @range = @maximum_stats-@minimum_stats - # @median = @sorted_numbers[((@count/2)+(1/2))] + @median = @sorted_numbers[((@count/2)+(1/2))] - # @sum = @numbers.sum + @sum = @numbers.sum - # @mean = @sum/@count + @mean = @sum/@count - # @demeaned=@numbers.map { |i| i - @mean} - # @squared = @demeaned.map { |i| i**2} - # @variance = @squared.sum / @count + @demeaned=@numbers.map { |i| i - @mean} + @squared = @demeaned.map { |i| i**2} + @variance = @squared.sum / @count - # @variance = @squared.sum / @count + @variance = @squared.sum / @count - # @standard_deviation = Math.sqrt(@variance) + @standard_deviation = Math.sqrt(@variance) - # @mode_count = @numbers.map { |i| @numbers.count(i)} - # @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] + @mode_count = @numbers.map { |i| @numbers.count(i)} + @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] - # render("calculations/stats_form_template.html.erb") - # end + render("calculations/stats_form_template.html.erb") + end From 8e3b84bfab4fce7336d110c6d1c82c7bcd2803b9 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 15:17:56 +0000 Subject: [PATCH 20/46] forms --- 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 5f3cb30..acbf773 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -28,7 +28,7 @@ def flex_payment @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex*10000 @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 -# @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> + # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> # <%= number_to_currency(@number_of_years_flex) %> @@ -90,7 +90,7 @@ def payment_form @monthly_interest_percentage_flex = (@monthly_interest_basispoints_flex*10000).to_i @monthly_interest_per_period_flex = (@monthly_interest_percentage_flex/12).to_i -# @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> + # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> # <%= number_to_currency(@number_of_years_flex) %> From 65f3445aab1b093237ba64fb44af0f3c2ef526b4 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 15:27:29 +0000 Subject: [PATCH 21/46] grade run --- app/views/calculations/square_root_form_template.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/calculations/square_root_form_template.html.erb b/app/views/calculations/square_root_form_template.html.erb index 8ee8442..ba54afd 100644 --- a/app/views/calculations/square_root_form_template.html.erb +++ b/app/views/calculations/square_root_form_template.html.erb @@ -9,7 +9,7 @@ - + From ec9cdcc8ad16b5f95c5fb6d9416168f6a15971ee Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 15:31:19 +0000 Subject: [PATCH 22/46] square --- app/controllers/calculations_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index acbf773..0f6a92e 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -25,8 +25,8 @@ def flex_payment @number_of_years_flex = params["number_of_years"].to_i @present_value_flex = params["present_value"].to_i - @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex*10000 - @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 + @monthly_interest_percentage_flex = (@monthly_interest_basispoints_flex*10000).to_i + @monthly_interest_per_period_flex = (@monthly_interest_percentage_flex/12).to_i # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> @@ -34,11 +34,11 @@ def flex_payment # number_of_monthly_payments_flex = @number_of_years*-12 - @one_plus_rate_per_period = (1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex + @one_plus_rate_per_period = ((1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex).to_i + + @denomonator_step_one = (1 - @one_plus_rate_per_period).to_i - @denomonator_step_one = 1 - @one_plus_rate_per_period - # - @numerator = (@monthly_interest_per_period_flex*@present_value_flex) + @numerator = (@monthly_interest_per_period_flex*@present_value_flex).to_i @denomonator = @denomonator_step_one @monthly_payment_flex = @numerator/@denomonator From 252088ebb9ae17b289b4b562313905e796d9ac81 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 15:36:45 +0000 Subject: [PATCH 23/46] square root form fixed --- app/controllers/calculations_controller.rb | 2 +- config/routes.rb | 26 +++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0f6a92e..88e48fb 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -77,7 +77,7 @@ def square_root_form @user_number_square_root = params["square_root_number"].to_i @squared_root = Math.sqrt(@user_number_square_root) - render("calculations/square_form_template.html.erb") + render("calculations/square_root_form_template.html.erb") end diff --git a/config/routes.rb b/config/routes.rb index e47ca25..18e8005 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,18 +12,32 @@ get("/flexible/random/:random_number_flex", {:controller => "calculations", :action => "flex_random_number" }) + + get("/square/new", { :controller => "calculations", :action => "square_form"}) - get("/square/:user_number", { :controller => "calculations", :action => "square_form"}) + get("/square_root/new", { :controller => "calculations", :action => "square_root_form"}) - get("square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form"}) + get("/payment/new", { :controller => "calculations", :action => "payment_form"}) - get("/payment/:basis_points/:number_of_years/:present_value", { :controller => "calculations", :action => "payment_form"}) + get("random/new", { :controller => "calculations", :action => "random_number_form"}) - get("random/:min/:max", { :controller => "calculations", :action => "random_number_form"}) - get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) + # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) - get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) + # get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) + + + # get("/square/:user_number", { :controller => "calculations", :action => "square_form"}) + + # get("square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form"}) + + # get("/payment/:basis_points/:number_of_years/:present_value", { :controller => "calculations", :action => "payment_form"}) + + # get("random/:min/:max", { :controller => "calculations", :action => "random_number_form"}) + + # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) + + # get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) From c7802179c40be54706b90df8af5919178a06c105 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 15:45:04 +0000 Subject: [PATCH 24/46] Adjustments --- .../calculations/flexible_payment_template.html.erb | 2 +- .../calculations/payment_results_template.html.erb | 6 +++--- config/routes.rb | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/calculations/flexible_payment_template.html.erb b/app/views/calculations/flexible_payment_template.html.erb index fba4bed..373e217 100644 --- a/app/views/calculations/flexible_payment_template.html.erb +++ b/app/views/calculations/flexible_payment_template.html.erb @@ -1,3 +1,3 @@

Flexible Payment

-

A <%= @number_of_years_flex %> year loan of <%= @present_value_flex %>, with an interest rate of is <%= @monthly_interest_percentage_flex %>%, requires a monthly payment of <%= @monthly_payment_flex %>

\ No newline at end of file +

A <%= @number_of_years_flex %> year loan of number_to_currency(<%= @present_value_flex %>), with an interest rate of is number_to_percentage(<%= @monthly_interest_percentage_flex %>), requires a monthly payment of number_to_currency(<%= @monthly_payment_flex %>)

\ No newline at end of file diff --git a/app/views/calculations/payment_results_template.html.erb b/app/views/calculations/payment_results_template.html.erb index 84ae7d8..3090f1b 100644 --- a/app/views/calculations/payment_results_template.html.erb +++ b/app/views/calculations/payment_results_template.html.erb @@ -5,7 +5,7 @@
- <%= @monthly_interest_percentage %> + number_to_percentage(<%= @monthly_interest_percentage %>)
@@ -21,7 +21,7 @@
- <%= @principal %> + number_to_currency(<%= @principal %>)
@@ -29,7 +29,7 @@
- <%= @monthly_payment%> + number_to_currency(<%= @monthly_payment%>)
Calculate another payment \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 18e8005..f53bb95 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,21 +19,21 @@ get("/payment/new", { :controller => "calculations", :action => "payment_form"}) - get("random/new", { :controller => "calculations", :action => "random_number_form"}) + get("/random/new", { :controller => "calculations", :action => "random_number_form"}) - # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) + get("/word_count/:user_text/new", {:controller => "calculations", :action => "word_count_form"}) - # get("/descriptive_stats/:list_of_numbers", {:controller => "calculations", :action => "stats_form"}) + get("/descriptive_stats/new", {:controller => "calculations", :action => "stats_form"}) # get("/square/:user_number", { :controller => "calculations", :action => "square_form"}) - # get("square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form"}) + # get("/square_root/:square_root_number", { :controller => "calculations", :action => "square_root_form"}) # get("/payment/:basis_points/:number_of_years/:present_value", { :controller => "calculations", :action => "payment_form"}) - # get("random/:min/:max", { :controller => "calculations", :action => "random_number_form"}) + # get("/random/:min/:max", { :controller => "calculations", :action => "random_number_form"}) # get("/word_count/:user_text/:special_word", {:controller => "calculations", :action => "word_count_form"}) From d158209b12bbe5c2b0a069c3e8c1339d2e11729f Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 16:08:45 +0000 Subject: [PATCH 25/46] payment --- app/controllers/calculations_controller.rb | 15 +++++++++------ .../flexible_payment_template.html.erb | 2 +- .../payment_results_template.html.erb | 6 +++--- config/routes.rb | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 88e48fb..8a1f01a 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -25,8 +25,8 @@ def flex_payment @number_of_years_flex = params["number_of_years"].to_i @present_value_flex = params["present_value"].to_i - @monthly_interest_percentage_flex = (@monthly_interest_basispoints_flex*10000).to_i - @monthly_interest_per_period_flex = (@monthly_interest_percentage_flex/12).to_i + # @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex*10000 + # @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> @@ -34,12 +34,15 @@ def flex_payment # number_of_monthly_payments_flex = @number_of_years*-12 - @one_plus_rate_per_period = ((1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex).to_i + # @one_plus_rate_per_period = (1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex - @denomonator_step_one = (1 - @one_plus_rate_per_period).to_i + # @denomonator_step_one = 1 - @one_plus_rate_per_period - @numerator = (@monthly_interest_per_period_flex*@present_value_flex).to_i - @denomonator = @denomonator_step_one + @numerator = 100000 + @denomonator = 50 + + # @numerator = @monthly_interest_per_period_flex*@present_value_flex + # @denomonator = @denomonator_step_one @monthly_payment_flex = @numerator/@denomonator diff --git a/app/views/calculations/flexible_payment_template.html.erb b/app/views/calculations/flexible_payment_template.html.erb index 373e217..630285e 100644 --- a/app/views/calculations/flexible_payment_template.html.erb +++ b/app/views/calculations/flexible_payment_template.html.erb @@ -1,3 +1,3 @@

Flexible Payment

-

A <%= @number_of_years_flex %> year loan of number_to_currency(<%= @present_value_flex %>), with an interest rate of is number_to_percentage(<%= @monthly_interest_percentage_flex %>), requires a monthly payment of number_to_currency(<%= @monthly_payment_flex %>)

\ No newline at end of file +

A <%= @number_of_years_flex %> year loan of <%= number_to_currency(@present_value_flex) %>, with an interest rate of is <%= number_to_percentage(@monthly_interest_percentage_flex) %>, requires a monthly payment of <%= number_to_currency(@monthly_payment_flex) %>

\ No newline at end of file diff --git a/app/views/calculations/payment_results_template.html.erb b/app/views/calculations/payment_results_template.html.erb index 3090f1b..c95d811 100644 --- a/app/views/calculations/payment_results_template.html.erb +++ b/app/views/calculations/payment_results_template.html.erb @@ -5,7 +5,7 @@
- number_to_percentage(<%= @monthly_interest_percentage %>) + <%= number_to_percentage(@monthly_interest_percentage) %>
@@ -21,7 +21,7 @@
- number_to_currency(<%= @principal %>) + <%= number_to_currency(@principal) %>
@@ -29,7 +29,7 @@
- number_to_currency(<%= @monthly_payment%>) + <%= number_to_currency(@monthly_payment) %>
Calculate another payment \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f53bb95..3826aa4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,7 +22,7 @@ get("/random/new", { :controller => "calculations", :action => "random_number_form"}) - get("/word_count/:user_text/new", {:controller => "calculations", :action => "word_count_form"}) + get("/word_count/new", {:controller => "calculations", :action => "word_count_form"}) get("/descriptive_stats/new", {:controller => "calculations", :action => "stats_form"}) From 4ee8a1d70a03ceb0b402cecbb11e8d3804d01147 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 16:15:26 +0000 Subject: [PATCH 26/46] payment - not working --- app/controllers/calculations_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 8a1f01a..5f25429 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -25,7 +25,7 @@ def flex_payment @number_of_years_flex = params["number_of_years"].to_i @present_value_flex = params["present_value"].to_i - # @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex*10000 + @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/10000 # @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> @@ -38,13 +38,12 @@ def flex_payment # @denomonator_step_one = 1 - @one_plus_rate_per_period - @numerator = 100000 - @denomonator = 50 - # @numerator = @monthly_interest_per_period_flex*@present_value_flex # @denomonator = @denomonator_step_one - @monthly_payment_flex = @numerator/@denomonator + # @monthly_payment_flex = @numerator/@denomonator + + @monthly_payment_flex = @monthly_interest_percentage_flex/12 render("calculations/flexible_payment_template.html.erb") end From b3cf60c47fdadab38bc5d9a41b30493df3ef3ee8 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 16:19:44 +0000 Subject: [PATCH 27/46] qwrwesytu --- app/controllers/calculations_controller.rb | 4 ++-- app/views/calculations/flexible_payment_template.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 5f25429..c73f1ea 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -26,7 +26,7 @@ def flex_payment @present_value_flex = params["present_value"].to_i @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/10000 - # @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 + @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> @@ -43,7 +43,7 @@ def flex_payment # @monthly_payment_flex = @numerator/@denomonator - @monthly_payment_flex = @monthly_interest_percentage_flex/12 + @monthly_payment_flex = 45645 render("calculations/flexible_payment_template.html.erb") end diff --git a/app/views/calculations/flexible_payment_template.html.erb b/app/views/calculations/flexible_payment_template.html.erb index 630285e..8a8f8a1 100644 --- a/app/views/calculations/flexible_payment_template.html.erb +++ b/app/views/calculations/flexible_payment_template.html.erb @@ -1,3 +1,3 @@

Flexible Payment

-

A <%= @number_of_years_flex %> year loan of <%= number_to_currency(@present_value_flex) %>, with an interest rate of is <%= number_to_percentage(@monthly_interest_percentage_flex) %>, requires a monthly payment of <%= number_to_currency(@monthly_payment_flex) %>

\ No newline at end of file +

A <%= @number_of_years_flex %> year loan of <%= number_to_currency(@present_value_flex) %>, with an interest rate of is <%= number_to_percentage(@monthly_interest_basispoints_flex/100) %>, requires a monthly payment of <%= number_to_currency(@monthly_payment_flex) %>

\ No newline at end of file From b18e0329adbadabe69458d0596be7b5c76cc35c8 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 16:31:12 +0000 Subject: [PATCH 28/46] getting there on monthly --- app/controllers/calculations_controller.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index c73f1ea..6f21e95 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -28,22 +28,17 @@ def flex_payment @monthly_interest_percentage_flex = @monthly_interest_basispoints_flex/10000 @monthly_interest_per_period_flex = @monthly_interest_percentage_flex/12 - # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> - - # <%= number_to_currency(@number_of_years_flex) %> + @number_of_monthly_payments_flex = @number_of_years_flex*-12 - # number_of_monthly_payments_flex = @number_of_years*-12 + @one_plus_rate_per_period = (1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex - # @one_plus_rate_per_period = (1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex + @denomonator_step_one = (1 - @one_plus_rate_per_period) - # @denomonator_step_one = 1 - @one_plus_rate_per_period - - # @numerator = @monthly_interest_per_period_flex*@present_value_flex - # @denomonator = @denomonator_step_one - - # @monthly_payment_flex = @numerator/@denomonator + @numerator = (@monthly_interest_per_period_flex*@present_value_flex).to_i + @denomonator = (@denomonator_step_one).to_i - @monthly_payment_flex = 45645 + @monthly_payment_flex = (1 - @one_plus_rate_per_period) + @test = (1 - @one_plus_rate_per_period) render("calculations/flexible_payment_template.html.erb") end From 617e5a77c272d5ab15daf3c04f9018c6a085bb3a Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 16:46:37 +0000 Subject: [PATCH 29/46] payment calculation complete --- app/controllers/calculations_controller.rb | 33 ++++++++----------- .../payment_results_template.html.erb | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 6f21e95..b7b795f 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -21,7 +21,7 @@ def flex_square_root def flex_payment - @monthly_interest_basispoints_flex = params["basis_points"].to_i + @monthly_interest_basispoints_flex = params["basis_points"].to_f @number_of_years_flex = params["number_of_years"].to_i @present_value_flex = params["present_value"].to_i @@ -37,8 +37,8 @@ def flex_payment @numerator = (@monthly_interest_per_period_flex*@present_value_flex).to_i @denomonator = (@denomonator_step_one).to_i - @monthly_payment_flex = (1 - @one_plus_rate_per_period) - @test = (1 - @one_plus_rate_per_period) + @monthly_payment_flex = @numerator/(1-(1+@monthly_interest_per_period_flex)**(@number_of_monthly_payments_flex)) + render("calculations/flexible_payment_template.html.erb") end @@ -80,28 +80,23 @@ def square_root_form def payment_form - @monthly_interest_basispoints_flex = params["basis_points"].to_i - @number_of_years_flex = params["number_of_years"].to_i - @present_value_flex = params["present_value"].to_i - - @monthly_interest_percentage_flex = (@monthly_interest_basispoints_flex*10000).to_i - @monthly_interest_per_period_flex = (@monthly_interest_percentage_flex/12).to_i - - # @monthly_interest_percent_flex = <%= number_to_percentage(@monthly_interest_basispoints_flex) %> - - # <%= number_to_currency(@number_of_years_flex) %> + @monthly_interest_basispoints = params["basis_points"].to_f + @number_of_years = params["number_of_years"].to_i + @present_value = params["present_value"].to_i - # number_of_monthly_payments_flex = @number_of_years*-12 + @monthly_interest_percentage = @monthly_interest_basispoints/10000 + @monthly_interest_per_period = @monthly_interest_percentage/12 - @one_plus_rate_per_period = ((1 + @monthly_interest_per_period_flex)**@number_of_monthly_payments_flex).to_i + @number_of_monthly_payments = @number_of_years*-12 - @numerator = (@monthly_interest_per_period_flex*@present_value_flex).to_i + @one_plus_rate_per_period = (1 + @monthly_interest_per_period)**@number_of_monthly_payments - @denomonator_step_one = (1 - @one_plus_rate_per_period).to_i + @denomonator_step_one = (1 - @one_plus_rate_per_period) - @denomonator = @denomonator_step_one + @numerator = (@monthly_interest_per_period*@present_value).to_i + @denomonator = (@denomonator_step_one).to_i - @monthly_payment_flex = @numerator/@denomonator + @monthly_payment = @numerator/(1-(1+@monthly_interest_per_period)**(@number_of_monthly_payments)) render("calculations/payment_form_template.html.erb") end diff --git a/app/views/calculations/payment_results_template.html.erb b/app/views/calculations/payment_results_template.html.erb index c95d811..44fd34e 100644 --- a/app/views/calculations/payment_results_template.html.erb +++ b/app/views/calculations/payment_results_template.html.erb @@ -5,7 +5,7 @@
- <%= number_to_percentage(@monthly_interest_percentage) %> + <%= number_to_percentage(@monthly_interest_basispoints) %>
From 2938b6100ac291d725ca0d6ae84be572b2eadbad Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 17:02:49 +0000 Subject: [PATCH 30/46] connecting forms --- app/controllers/calculations_controller.rb | 6 +++--- .../calculations/payment_form_template.html.erb | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index b7b795f..cdeda16 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -80,9 +80,9 @@ def square_root_form def payment_form - @monthly_interest_basispoints = params["basis_points"].to_f - @number_of_years = params["number_of_years"].to_i - @present_value = params["present_value"].to_i + @monthly_interest_basispoints = params["interest_input"].to_f + @number_of_years = params["years_input"].to_i + @present_value = params["principal_input"].to_i @monthly_interest_percentage = @monthly_interest_basispoints/10000 @monthly_interest_per_period = @monthly_interest_percentage/12 diff --git a/app/views/calculations/payment_form_template.html.erb b/app/views/calculations/payment_form_template.html.erb index abffadf..0b5b851 100644 --- a/app/views/calculations/payment_form_template.html.erb +++ b/app/views/calculations/payment_form_template.html.erb @@ -1,12 +1,13 @@

Payment Calculation

-
+ +
- +
@@ -14,7 +15,7 @@ Number of Years - +
@@ -22,9 +23,12 @@ Principal - +
- + + + +
From 9aed5101a6975e4cbe1d2bd808e47ad6dd1de601 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 17:12:28 +0000 Subject: [PATCH 31/46] getting forms and results pages linked --- app/controllers/calculations_controller.rb | 14 +++++++------- .../random_number_form_template.html.erb | 4 ++-- .../square_root_form_template.html.erb | 2 +- .../calculations/stats_form_template.html.erb | 2 +- .../calculations/word_count_form_template.html.erb | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index cdeda16..2d64d73 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -62,7 +62,7 @@ def flex_random_number def square_form - @user_number = params["user_number"].to_i + @user_number = params["number_input"].to_i @squared_number = @user_number**2 render("calculations/square_form_template.html.erb") @@ -71,7 +71,7 @@ def square_form def square_root_form - @user_number_square_root = params["square_root_number"].to_i + @user_number_square_root = params["number_input_square_root"].to_i @squared_root = Math.sqrt(@user_number_square_root) render("calculations/square_root_form_template.html.erb") @@ -104,8 +104,8 @@ def payment_form def random_number_form - @minimum = params["min"].to_i - @maximum = params["max"].to_i + @minimum = params["random_minimum_input"].to_i + @maximum = params["random_maximum_input"].to_i @random_number_output = rand(@minimum...@maximum) render("calculations/random_number_form_template.html.erb") @@ -114,8 +114,8 @@ def random_number_form def word_count_form - @text = params[:user_text] - @special_word = params[:special_word] + @text = params["word_count_input"] + @special_word = params["special_word_input"] @word_count = @text.split(" ").length @@ -138,7 +138,7 @@ def word_count_form def stats_form - @numbers = params[:list_of_numbers].gsub(',', '').split.map(&:to_f) + @numbers = params["list_of_numbers_input"].gsub(',', '').split.map(&:to_f) @sorted_numbers = @numbers.sort diff --git a/app/views/calculations/random_number_form_template.html.erb b/app/views/calculations/random_number_form_template.html.erb index b8eb05c..2ca3a50 100644 --- a/app/views/calculations/random_number_form_template.html.erb +++ b/app/views/calculations/random_number_form_template.html.erb @@ -6,7 +6,7 @@ Minimum - +
@@ -14,7 +14,7 @@ Maximum - +
diff --git a/app/views/calculations/square_root_form_template.html.erb b/app/views/calculations/square_root_form_template.html.erb index ba54afd..28b0eb0 100644 --- a/app/views/calculations/square_root_form_template.html.erb +++ b/app/views/calculations/square_root_form_template.html.erb @@ -6,7 +6,7 @@ Enter a number - + diff --git a/app/views/calculations/stats_form_template.html.erb b/app/views/calculations/stats_form_template.html.erb index bc65b99..9d32477 100644 --- a/app/views/calculations/stats_form_template.html.erb +++ b/app/views/calculations/stats_form_template.html.erb @@ -6,7 +6,7 @@ Numbers - + diff --git a/app/views/calculations/word_count_form_template.html.erb b/app/views/calculations/word_count_form_template.html.erb index a10f4a9..7f9ebdb 100644 --- a/app/views/calculations/word_count_form_template.html.erb +++ b/app/views/calculations/word_count_form_template.html.erb @@ -14,7 +14,7 @@ Special word - + From 6b4fcf3fa9e75f62b25056e4f05bc831bc9d5715 Mon Sep 17 00:00:00 2001 From: Em Klick Date: Tue, 18 Jul 2017 18:22:42 +0000 Subject: [PATCH 32/46] connections --- app/controllers/calculations_controller.rb | 126 +++++++++++++++++- .../payment_form_template.html.erb | 2 +- .../payment_results_template.html.erb | 35 ----- .../process_payment_form_template.html.erb | 18 +++ ...ocess_random_number_form_template.html.erb | 15 +++ .../process_square_form_template.html.erb | 12 ++ ...process_square_root_form_template.html.erb | 12 ++ ...b => process_stats_form_template.html.erb} | 0 ...process_word_count_form_template.html.erb} | 0 .../random_number_form_template.html.erb | 6 +- .../random_number_results_template.html.erb | 27 ---- .../square_form_template.html.erb | 6 +- .../square_results_template.html.erb | 20 --- .../square_root_form_template.html.erb | 8 +- .../square_root_results_template.html.erb | 20 --- config/routes.rb | 17 ++- 16 files changed, 202 insertions(+), 122 deletions(-) delete mode 100644 app/views/calculations/payment_results_template.html.erb create mode 100644 app/views/calculations/process_payment_form_template.html.erb create mode 100644 app/views/calculations/process_random_number_form_template.html.erb create mode 100644 app/views/calculations/process_square_form_template.html.erb create mode 100644 app/views/calculations/process_square_root_form_template.html.erb rename app/views/calculations/{stats_results_template.html.erb => process_stats_form_template.html.erb} (100%) rename app/views/calculations/{word_count_results_template.html.erb => process_word_count_form_template.html.erb} (100%) delete mode 100644 app/views/calculations/random_number_results_template.html.erb delete mode 100644 app/views/calculations/square_results_template.html.erb delete mode 100644 app/views/calculations/square_root_results_template.html.erb diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 2d64d73..a1ffe4d 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -62,7 +62,7 @@ def flex_random_number def square_form - @user_number = params["number_input"].to_i + @user_number = params["the_user_number"].to_i @squared_number = @user_number**2 render("calculations/square_form_template.html.erb") @@ -80,9 +80,9 @@ def square_root_form def payment_form - @monthly_interest_basispoints = params["interest_input"].to_f - @number_of_years = params["years_input"].to_i - @present_value = params["principal_input"].to_i + @monthly_interest_basispoints = params["the_user_interest"].to_f + @number_of_years = params["the_user_payment_years"].to_i + @present_value = params["the_user_principal"].to_i @monthly_interest_percentage = @monthly_interest_basispoints/10000 @monthly_interest_per_period = @monthly_interest_percentage/12 @@ -104,8 +104,8 @@ def payment_form def random_number_form - @minimum = params["random_minimum_input"].to_i - @maximum = params["random_maximum_input"].to_i + @minimum = params["minimum"].to_f + @maximum = params["maximum"].to_f @random_number_output = rand(@minimum...@maximum) render("calculations/random_number_form_template.html.erb") @@ -172,5 +172,119 @@ def stats_form + + def process_square_form + + # The incoming parameters for this action look like {"the_user_number"} => "5" + # Rails stores that hash in a variable called params + + @user_number = params["the_user_number"].to_f + @squared_number = @user_number**2 + + render("calculations/process_square_form_template.html.erb") + end + + def process_square_root_form + + @user_number_root = params["the_user_number_square_root"].to_f + @squared_root = Math.sqrt(@user_number_root) + + render("calculations/process_square_root_form_template.html.erb") + end + + + def process_payment_form + + @monthly_interest_basispoints = params["the_user_interest"].to_f + @number_of_years = params["the_user_payment_years"].to_i + @present_value = params["the_user_principal"].to_i + + @monthly_interest_percentage = @monthly_interest_basispoints/10000 + @monthly_interest_per_period = @monthly_interest_percentage/12 + + @number_of_monthly_payments = @number_of_years*-12 + + @one_plus_rate_per_period = (1 + @monthly_interest_per_period)**@number_of_monthly_payments + + @denomonator_step_one = (1 - @one_plus_rate_per_period) + + @numerator = (@monthly_interest_per_period*@present_value).to_i + @denomonator = (@denomonator_step_one).to_i + + @monthly_payment = @numerator/(1-(1+@monthly_interest_per_period)**(@number_of_monthly_payments)) + + render("calculations/process_payment_form_template.html.erb") + end + + + def process_random_number_form + + @minimum = params["minimum"].to_f + @maximum = params["maximum"].to_f + @random_number_output = rand(@minimum...@maximum) + + render("calculations/process_random_number_form_template.html.erb") + end + + + def process_word_count_form + + @text = params["word_count_input"] + @special_word = params["special_word_input"] + + @word_count = @text.split(" ").length + + @character_count_with_spaces = @text.length + + @character_count_without_spaces = @text.length-@text.count(" ") + + punctuation = @text.chomp(".") + + downcased_words = punctuation.downcase.split(" ") + + downcased_special = @special_word.downcase + + @occurrences = downcased_words.count(downcased_special) + + + render("calculations/process_word_count_form_template.html.erb") + end + + + def process_stats_form + + @numbers = params["list_of_numbers_input"].gsub(',', '').split.map(&:to_f) + + @sorted_numbers = @numbers.sort + + @count = @numbers.count + + @minimum_stats = @numbers.min + + @maximum_stats = @numbers.max + + @range = @maximum_stats-@minimum_stats + + @median = @sorted_numbers[((@count/2)+(1/2))] + + @sum = @numbers.sum + + @mean = @sum/@count + + @demeaned=@numbers.map { |i| i - @mean} + @squared = @demeaned.map { |i| i**2} + @variance = @squared.sum / @count + + @variance = @squared.sum / @count + + @standard_deviation = Math.sqrt(@variance) + + @mode_count = @numbers.map { |i| @numbers.count(i)} + @mode = @numbers[@mode_count.index(@mode_count.sort[@mode_count.count - 1])] + + render("calculations/process_stats_form_template.html.erb") + end + + end diff --git a/app/views/calculations/payment_form_template.html.erb b/app/views/calculations/payment_form_template.html.erb index 0b5b851..e364576 100644 --- a/app/views/calculations/payment_form_template.html.erb +++ b/app/views/calculations/payment_form_template.html.erb @@ -1,6 +1,6 @@

Payment Calculation

-
+
+ - - \ No newline at end of file + + \ No newline at end of file diff --git a/public/homepage.html b/public/homepage.html index 0c932df..8496925 100644 --- a/public/homepage.html +++ b/public/homepage.html @@ -1,65 +1,103 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Target Omnicalc Params + + + + + + + + +
+
+
+ +
Part I Targets - Flexible Square Example - - Flexible Square Root Example - - Flexible Payment Example - - Flexible Random Example -
Part II Targets - Square Form - - Square Root Form - - Payment Form - - Random Number Form -
Part III Targets - Word Count Form - - Stats Form -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Part I Targets + + Flexible Square Example + + Flexible Square Root Example + + Flexible Payment Example + + Flexible Random Example +
+ Part II Targets + + Square Form + + Square Root Form + + Payment Form + + Random Number Form +
+ Part III Targets + + Word Count Form + + Stats Form +
+ +

+ Square Calculation +

+ +
+
+ + + +
+ + +
+ + + + - - \ No newline at end of file + + \ No newline at end of file