I am having troubles with my programming I'm new on this java program and need to do this.
The goal of this programming assignment is to find the sum of
1/1 + 1/2 + 1/3 + ... + 1/1000 in terms of a fraction, not as decimal
number. I can use Provide methods display(),
isWhole(), returnNumerator(), returnDenominator(), returnDecimal().
thanks for help....
1 reply to this topic
#1
Posted 28 November 2010 - 09:27 AM
|
|
|
#2
Posted 28 November 2010 - 10:15 AM
Do you HAVE TO use/code these methods?
display(), isWhole(), returnNumerator(), returnDenominator(), returnDecimal().
I mean, if you rewrite 1/1 + 1/2 + 1/3 + ... you can get this:
(1000/1)/1000 + (1000/2)/1000 + (1000/3)/1000 ...
To display it as fraction you just drop all the /1000
double result = (1000/1)+ (1000/2)/+ (1000/3) +...
and then display as fraction:
System.out.println(result +"/1000");
You just need to calculate the result with use of a loop and you're done.. no idea why you would need so many methods.. i'd have like ..2 methods :D calculate(), and display()
display(), isWhole(), returnNumerator(), returnDenominator(), returnDecimal().
I mean, if you rewrite 1/1 + 1/2 + 1/3 + ... you can get this:
(1000/1)/1000 + (1000/2)/1000 + (1000/3)/1000 ...
To display it as fraction you just drop all the /1000
double result = (1000/1)+ (1000/2)/+ (1000/3) +...
and then display as fraction:
System.out.println(result +"/1000");
You just need to calculate the result with use of a loop and you're done.. no idea why you would need so many methods.. i'd have like ..2 methods :D calculate(), and display()
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









