Check08B - ... " + investments.size() +...

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

View Full Document Right Arrow Icon
import java.io.*; i import type.lib.*; i public class Check08B { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader buffer = new BufferedReader( new InputStreamReader(System.in)); PrintStream out = System.out; out.print("Cutoff Price. ....... "); int cutOffPrice = Integer.parseInt(buffer.readLine()); Portfolio investments = Portfolio.getRandom(); out.println("Portfolio Name. ..... " + investments.getName()); out.println("Portfolio Capacity. . " + investments.getCapacity()); out.println("Investment Count.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ... " + investments.size() + "\n"); double portfolioValue = 0; for (Investment inv : investments) { if (inv.getStock().getPrice() < cutOffPrice) { out.printf("%d\t%.2f\t%s%n", inv.getQty(), inv.getStock().getPrice(), inv.getStock().getName()); portfolioValue += inv.getQty() * inv.getStock().getPrice(); } } if (portfolioValue > 0) { out.printf("%nValue of portfolio below cutoff is: %,.2f%n", portfolioValue); } else { out.printf("%nThere are no stocks below your cutoff!%n"); } } }...
View Full Document

Ask a homework question - tutors are online