Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end


gem 'momentjs-rails'
gem 'bootstrap3-datetimepicker-rails'
gem 'chronic'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'
# Use sqlite3 as the database for Active Record
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ GEM
bootstrap (4.0.0.alpha6)
autoprefixer-rails (>= 6.0.3)
sass (>= 3.4.19)
bootstrap3-datetimepicker-rails (4.17.47)
momentjs-rails (>= 2.8.1)
builder (3.2.3)
byebug (9.0.6)
callsite (0.0.11)
Expand All @@ -85,6 +87,7 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
chronic (0.10.2)
coderay (1.1.1)
concurrent-ruby (1.0.5)
crack (0.4.3)
Expand Down Expand Up @@ -140,6 +143,8 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.2)
momentjs-rails (2.17.1)
railties (>= 3.1)
multi_json (1.12.1)
nio4r (2.1.0)
nokogiri (1.8.0)
Expand Down Expand Up @@ -262,8 +267,10 @@ DEPENDENCIES
better_errors
binding_of_caller
bootstrap (~> 4.0.0.alpha6)
bootstrap3-datetimepicker-rails
byebug
capybara
chronic
dotenv-rails
factory_girl_rails
firstdraft_generators
Expand All @@ -274,6 +281,7 @@ DEPENDENCIES
letter_opener
listen (>= 3.0.5, < 3.2)
meta_request
momentjs-rails
pry-rails
puma (~> 3.7)
rails (~> 5.1.2)
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@
//= require bootstrap
//= require turbolinks
//= require_tree .
//= require jquery
//= require moment
//= require bootstrap-datetimepicker

$(function () {
$('.datetimepicker').datetimepicker();
});
108 changes: 86 additions & 22 deletions app/controllers/calculations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def word_count
# ================================================================================


@word_count = "Replace this string with your answer."
@word_count = @text.split.count

@character_count_with_spaces = "Replace this string with your answer."
@character_count_with_spaces = @text.length

@character_count_without_spaces = "Replace this string with your answer."
@character_count_without_spaces = @text.gsub(/\s+/, "").length

@occurrences = "Replace this string with your answer."
@occurrences = @text.split.count(@special_word)

# ================================================================================
# Your code goes above.
Expand All @@ -38,7 +38,13 @@ def loan_payment
# The principal value the user input is in the decimal @principal.
# ================================================================================

@monthly_payment = "Replace this string with your answer."
term_months = @years * 12
new_apr = @apr * 1/100
principal_month = @principal / term_months
interest_term = @principal * new_apr
interest_month = interest_term / term_months

@monthly_payment = principal_month + interest_month

# ================================================================================
# Your code goes above.
Expand All @@ -60,12 +66,35 @@ def time_between
# number of seconds as a result.
# ================================================================================

@seconds = "Replace this string with your answer."
@minutes = "Replace this string with your answer."
@hours = "Replace this string with your answer."
@days = "Replace this string with your answer."
@weeks = "Replace this string with your answer."
@years = "Replace this string with your answer."
@seconds = @ending - @starting

startt = @starting.to_f
endt = @ending.to_f

start_min=startt * 1/60
end_min=endt * 1/60

@minutes = end_min - start_min

start_hr=startt * 1/3600
end_hr=endt * 1/3600

@hours = end_hr - start_hr

start_day=start_hr * 1/24
end_day=end_hr * 1/24

@days = end_day - start_day

start_week=start_day * 1/7
end_week=end_day * 1/7

@weeks = end_week - start_week

start_year=start_week * 1/52
end_year=end_week * 1/52

@years = end_year - start_year

# ================================================================================
# Your code goes above.
Expand All @@ -82,27 +111,60 @@ def descriptive_statistics
# The numbers the user input are in the array @numbers.
# ================================================================================

@sorted_numbers = "Replace this string with your answer."
@sorted_numbers = @numbers.sort

@count = "Replace this string with your answer."
@count = @numbers.count

@minimum = "Replace this string with your answer."
@minimum = @numbers.min

@maximum = "Replace this string with your answer."
@maximum = @numbers.max

@range = "Replace this string with your answer."
@range = @maximum - @minimum

@median = "Replace this string with your answer."
sorted = @numbers.sort
len = sorted.length

@median = (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0

@sum = "Replace this string with your answer."
@sum = @numbers.sum

@mean = "Replace this string with your answer."
sum_calc = @sum.to_f
count_calc = @count.to_f

@variance = "Replace this string with your answer."
@mean = sum_calc / count_calc

sample = @numbers
xbar = @mean
variance_differential = []

sample.each do |num1|
number_less_xbar = num1 - xbar
variance_differential.push(number_less_xbar)
end

squared_results = []

variance_differential.each do |num2|
square = num2 * num2
squared_results.push(square)
end

results_sum = squared_results.sum

sample_size = @count - 1

@variance = results_sum / sample_size

@standard_deviation = "Replace this string with your answer."
@standard_deviation = Math.sqrt(@variance)

@mode = "Replace this string with your answer."
hash = Hash.new(0)
@numbers.each do |i|
hash[i]+=1
end

mode_max = hash.max

@mode = mode_max

# ================================================================================
# Your code goes above.
Expand All @@ -111,3 +173,5 @@ def descriptive_statistics
render("descriptive_statistics.html.erb")
end
end