Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ChallengeFive {
- // the current value of k
- static double k, sk;
- public static void main(String[] args) {
- // value of k^2
- double v;
- System.out.println("Value k and the sum: ");
- for (k = 1; k <= 20000; k++){
- v = Math.pow(k, 2);
- sk = ((v*10 - 4*k + 2)+sk);
- System.out.printf("%2.0f", k);
- System.out.print(", ");
- System.out.printf("%2.2f", sk);
- System.out.print(" ");
- System.out.println();
- if (sk > 20000){
- break;
- }
- }
- /*
- * Prints out all the final values
- */
- System.out.print("\nThe final value of k = " + k);
- System.out.print("\nThe final sum value = " + sk);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement