compound_interest_calculator 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/compound_interest_calculator +31 -0
- data/lib/compound_interest_calculator.rb +4 -26
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41af76b74ab1cb8212fa9e4762719ed9deb48198
|
4
|
+
data.tar.gz: 5c7c023ccaded4cad3f0af73e702394a1d7fe812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4edcbee1615a8990f5e4dccade19d7eb417d755c0d84290bd920053d49759e22ae6686bda08aa6f165a44e35f50585fd7e4f14a0846d87efc6c580076686cab3
|
7
|
+
data.tar.gz: 897b90fa56caa2493b8f2ba1b761118862feae538cde1050de926d147988cdda73e984397dc8cca5783b5e288d3439f4ec8e87157906bf550bb98198490a6d89
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "compound_interest_calculator"
|
4
|
+
|
5
|
+
@calculator = CompoundInterestCalculator.new
|
6
|
+
|
7
|
+
#Requests the principle amount.
|
8
|
+
puts "What's the initial amount you'd like to deposit?"
|
9
|
+
puts "Please type the amount below without commas or dollar signs."
|
10
|
+
principle = gets.to_f
|
11
|
+
|
12
|
+
#Requests the annual interest rate.
|
13
|
+
puts "What will the annual interest rate be?"
|
14
|
+
puts "Please leave the percentage sign off (i.e. 16% would be written as 16)."
|
15
|
+
interest = (gets.to_f)
|
16
|
+
|
17
|
+
#Requests the number of times the principle will be compounded each year.
|
18
|
+
puts "How many times will the deposit be compounded each year?"
|
19
|
+
puts "Please enter a whole number."
|
20
|
+
compound = gets.to_i
|
21
|
+
|
22
|
+
#Requests the amount of years that compound interest will take place.
|
23
|
+
puts "How many years will the deposit be compounded?"
|
24
|
+
puts "Please enter a whole number."
|
25
|
+
time = gets.to_i
|
26
|
+
|
27
|
+
result = @calculator.amount_earned(principle, interest, compound, time)
|
28
|
+
|
29
|
+
#Prints the final amount accumulated.
|
30
|
+
puts "Congratulations! You'll have $#{amount_earned} after #{time} years."
|
31
|
+
|
@@ -1,28 +1,6 @@
|
|
1
1
|
class CompoundInterestCalculator
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#Requests the annual interest rate.
|
9
|
-
puts "What will the annual interest rate be?"
|
10
|
-
puts "Please leave the percentage sign off (i.e. 16% would be written as 16)."
|
11
|
-
interest = (gets.to_f/100)
|
12
|
-
|
13
|
-
#Requests the number of times the principle will be compounded each year.
|
14
|
-
puts "How many times will the deposit be compounded each year?"
|
15
|
-
compound = gets.to_i
|
16
|
-
|
17
|
-
#Requests the amount of years that compound interest will take place.
|
18
|
-
puts "How many years will the deposit be compounded?"
|
19
|
-
time = gets.to_i
|
20
|
-
|
21
|
-
#Prints the final amount accumulated.
|
22
|
-
amount = (principle*(1 + interest/compound)**(compound*time)).round(2)
|
23
|
-
|
24
|
-
puts "You'll have $#{amount} after #{time} years."
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
|
3
|
+
def amount_earned(principle, interest, compound, time)
|
4
|
+
@result = (principle*(1 + (interest/100)/compound)**(compound*time)).round(2)
|
5
|
+
end
|
6
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compound_interest_calculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon LaFave
|
@@ -16,10 +16,12 @@ description: 'This gem calculates the amount of money earned over time through c
|
|
16
16
|
will be compounded each year. The program works, but the rspec tests don''t pass
|
17
17
|
yet.'
|
18
18
|
email: lafaveb@gmail.com
|
19
|
-
executables:
|
19
|
+
executables:
|
20
|
+
- compound_interest_calculator
|
20
21
|
extensions: []
|
21
22
|
extra_rdoc_files: []
|
22
23
|
files:
|
24
|
+
- bin/compound_interest_calculator
|
23
25
|
- lib/compound_interest_calculator.rb
|
24
26
|
homepage: http://rubygems.org/gems/compound_interest_calculator
|
25
27
|
licenses:
|