Hi everyone, I'm super new to
Java and taking an online course. I'm really struggling as the class is very poorly put together. I'm at the point where I have to do my first assignment and a question that I think should be easy is giving me trouble.
The question is:
Write a program that computes the following expression up to four (4) decimal places:
(1/10) + (2/9) + (3/8) + (4/7) + (5/6) + (6/5) + (7/4) + (8/3) + (9/2) + (10/1)
I know the correct answer is 22.2219, but when I do my program is comes up with 18.0000
I put the expression above into a double variable and when I print the variable I get 18.0000.
My instructor gave me a hint that I need to use a for-loop and its not as straight forward as it seems, but I dont understand what they want.
Any help would be appreciated.
Thanks