Created
February 10, 2012 22:38
-
-
Save sentientmachine/1793635 to your computer and use it in GitHub Desktop.
Problem 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package JavaApplication12; | |
import java.util.ArrayList; | |
public class Main{ | |
public static void main(String[] args) | |
{ | |
ArrayList<Double> arr = new ArrayList<Double>(); | |
double biggest_frequency_word = 2520; | |
arr.add(biggest_frequency_word); | |
double total = biggest_frequency_word; | |
for(int x = 0; x < 899; x++) | |
{ | |
double val = biggest_frequency_word / (x+2); | |
total += val; | |
arr.add(val); | |
} | |
System.out.println("total is: " + total); | |
int len = arr.size(); | |
double total_so_far = 0; | |
for(int x = 0; x < len; x++) | |
{ | |
total_so_far += arr.get(x); | |
if (total_so_far > (total / 2)) | |
{ | |
System.out.println("Heiten ze, Shtop, its ze Amarikan!" + (x+1)); //22, add one cuz we are zero based. | |
//yes yes I can make this more abstract and polymorphous if you want, this is very thrown together and hacky, If you want more you'll have to fly me over there. | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment