Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Future Value Calculator
Evan Cristofori
Greenhorn
Posts: 18
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
I was wondering if someone could show me an example of a future value calculator:
" F = P(1+rate)^t "
where
F = future value
P = initial deposit (principal)
rate = (annual) interest rate (expressed as a fraction, e.g. 0.06)
t = number of years invested
Also,
The user needs to be able too input each parameter:
"Please input the principal: ______"
"Please input the annual interest rate: ______"
"Please input the number of years invested: ______"
Then,
The program should run the calculator and output the information:
"The future value of your investment after ___ years is : ______"
Thanks,
Evan
Michael Dunn
Ranch Hand
Posts: 4632
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
> I was wondering if someone could show me an example of a future value calculator:
if you are a beginner, have a crack at it yourself - you'll learn more that
way (the downside is you may end up with a few self-inflicted wounds!)
if you get stuck, post a specific question and include the code you've tried.
Evan Cristofori
Greenhorn
Posts: 18
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hey,
I was going to... I just wanted to compare my results to someone elses.
Here is my code I came up with:
/** *The CompoundCalculatorApp class figures out the future value of an investment *after x years * *Author: Evan Cristofori *Date: 02/12/07 * */ import java.io.*; class CompoundCalculator { public static void main(String[] args) throws java.io.IOException { String s1, s2, s3; double p, r, f, rate; int t; InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); System.out.print("Please input the principal: "); s1 = br.readLine(); p = Double.parseDouble(s1); System.out.print("Please input the annual interest rate: "); s2 = br.readLine(); r = Double.parseDouble(s2); System.out.print("Please input the number of years invested: "); s3 = br.readLine(); t = Integer.parseInt(s3); rate = (1+r); f = p * Math.pow(rate, t); System.out.println("The future value of your investment after " + t + " years is: " + f); } }
How does it look?
Jesper de Jong
Java Cowboy
Posts: 16084
88
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It looks good.
Jesper's Blog
-
Pluralsight Author Page
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
I can't see the error in this page
Use of Math.pow?
New to ArrayList
JSP
Did I do this right? (Interest calculator)
More...