{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Check07C - int i = 1 double sum = 0 value do value = i i...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import type.lib.ToolBox; import java.io.PrintStream; import java.util.Scanner; i public class Check07C { public static void main(String[] args) { PrintStream out = System.out; Scanner in = new Scanner(System.in); out.print("Enter the value of x ... "); double x = in.nextDouble(); if (Math.abs(x) < 1) { final double TOLERANCE = 0.0001, THREE = 3.0, ORACLE = (1 + x) / Math.pow(1 - x, THREE);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int i = 1; double sum = 0, value; do { value = i * i * Math.pow(x, i - 1); sum = (Math.abs(value) > TOLERANCE) ? sum + value: sum; i++; } while (Math.abs(value) > TOLERANCE); out.println("The sum of the series = " + sum); out.println("The Oracle's answer is: " + ORACLE); } else { ToolBox.crash(x > 1, "|x| must be < 1."); } } }...
View Full Document

{[ snackBarMessage ]}