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) && !(diverse instanceof Money)) ? mix + 1 : mix; plus = (diverse.compareTo(new Fraction()) >= 0) ? plus + 1 : plus; } final double CENT = 100.0; out.printf("Sum\t%s%n", sum.toString()); out.printf("Mixed\t%.0f%s%n", mix / sample * CENT, ".%"); out.printf("Ptive\t%.0f%s%n", plus / sample * CENT, ".%"); } }...
View Full Document

  • Fall '10
  • Burton,Ma
  • new Fraction, final double CENT, diverse instanceof MixedNumber, diverse instanceof Money, public class Check09C

{[ snackBarMessage ]}

Ask a homework question - tutors are online