SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top