Advertisement
mcnealk

4-1

Oct 29th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class E1 here.
  4. *
  5. * @author Kailey McNeal
  6. * @version 10-24-14
  7. * p305 #1
  8. */
  9. public class E1
  10. {
  11. public static void main (String []args)
  12. {
  13. fractionSum(5);
  14. }
  15. public static void fractionSum(int n)
  16. {
  17. for (int i=1; i<=n; i++)
  18. {
  19. double div=(double)1/i;
  20. System.out.print(div);
  21. if(i<n)
  22. {
  23. System.out.print(" + ");
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement