Check07C - int i = 1; double sum = 0, value; do { value = 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) &gt; TOLERANCE) ? sum + value: sum; i++; } while (Math.abs(value) &gt; TOLERANCE); out.println(&quot;The sum of the series = &quot; + sum); out.println(&quot;The Oracle's answer is: &quot; + ORACLE); } else { ToolBox.crash(x &gt; 1, &quot;|x| must be &lt; 1.&quot;); } } }...
View Full Document

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

Ask a homework question - tutors are online