Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public class question3
  2. {
  3. public static void main(String[] args)
  4. {
  5. System.out.println("These tests are not always thorough. You need to do testing on your own as well to be certain your code is correct although these will help make sure you are on the right track!");
  6.  
  7. testGenerateBenfordSequence();
  8.  
  9. System.out.println("No test for main method. (Make sure to test this yourself!)");
  10. }
  11. private static void testGenerateBenfordSequence()
  12. {
  13. System.out.println("Testing generating the Benford sequence");
  14. double[] correct = {100, 110, 121, 133.1};
  15. validateSequence(100, .1, 4, correct); //<-------------------------(THIS PART ON validateSequence)
  16. System.out.println("Done testing generating the Benford sequence");
  17. }
  18. public static double[] generateBenfordNumbers(double initialAmount, double growthRate, int numberPeriods)
  19. {
  20. double[] sequence = new double[numberPeriods];
  21. for(int i=0; i<=numberPeriods; i++)
  22. {
  23. sequence[i] = initialAmount*(1 + growthRate);
  24. }
  25. return sequence;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement