Check09B - double balance = index.getBalance double limit =...

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 Check09B { public static void main(String[] args) { PrintStream out = System.out; out.print("Enter trigger level [1-100] . .. "); int triggerLevel = new Scanner(System.in).nextInt(); GlobalCredit variousCards = GlobalCredit.getRandom(); GlobalCredit rewardCards = new GlobalCredit(); double averageBalance = 0; for (CreditCard index : variousCards) { averageBalance += index.getBalance(); if (index instanceof RewardCard) { rewardCards.add(index); } } averageBalance = averageBalance / variousCards.size(); final double CENT = 100.0; for (CreditCard index : variousCards)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { double balance = index.getBalance(); double limit = index.getLimit(); String STAR = (balance > averageBalance) ? "*" : ""; String TAB = (balance / limit > triggerLevel / CENT) ? "<" : ""; out.printf("%s%s\t%d\t\t%.2f\t%s%n", index.getNumber(), STAR, (int) limit, balance, TAB); } double percent = Math.rint(rewardCards.size() * CENT / variousCards.size()); out.printf("%nNumber of cards = %d%n", variousCards.size()); out.printf("Percentage of reward cards = %d%s%n", (int) percent, "%"); out.printf("Average balance = %.2f%n", averageBalance); } }...
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