Check09C - sum.add(diverse); mix = ((diverse instanceof...

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

View Full Document Right Arrow Icon
import type.lib.*; import java.io.PrintStream; import java.util.Scanner; i public class Check09C { public static void main(String[] args) { PrintStream out = System.out; out.println("Sample size?"); int sample = new Scanner(System.in).nextInt(); Fraction sum = new Fraction(); double mix = 0, plus = 0; for (int i = 0; i < sample; i++) { Fraction diverse = Money.getRandom(); out.printf("%d\t%s%n", i, diverse.toString());
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sum.add(diverse); mix = ((diverse instanceof MixedNumber) &amp;&amp; !(diverse instanceof Money)) ? mix + 1 : mix; plus = (diverse.compareTo(new Fraction()) &gt;= 0) ? plus + 1 : plus; } final double CENT = 100.0; out.printf(&quot;Sum\t%s%n&quot;, sum.toString()); out.printf(&quot;Mixed\t%.0f%s%n&quot;, mix / sample * CENT, &quot;.%&quot;); out.printf(&quot;Ptive\t%.0f%s%n&quot;, plus / sample * CENT, &quot;.%&quot;); } }...
View Full Document

Ask a homework question - tutors are online