Check05B - totalValue = fileInput.nextInt record.getPrice else output.printf"d Symbol%s does not exist%n" i record.getSymbol

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

View Full Document Right Arrow Icon
import java.util.Scanner; import; import; import; import type.lib.Stock; //import javax.swing.JFileChooser; //(import only if you want a GUI window to selecting your file) / public class Check05B { public static void main(String[] args) throws FileNotFoundException { PrintStream output = System.out; output.print("Enter filename . .. "); Scanner fileInput = new Scanner( new File(new Scanner(; double totalValue = 0; for (int i = 0; fileInput.hasNext(); i += 2) { Stock record = new Stock(; if (record.getName() != null) { output.printf("%05d %.2f%n", i, record.getPrice());
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: totalValue += fileInput.nextInt() * record.getPrice(); } else { output.printf("%05d Symbol %s does not exist!%n", i, record.getSymbol());; } } output.printf("Total value = %.2f%n", totalValue); fileInput.close(); } } //E:\Documents and Settings\Dennis\My Documents\lab5data.txt / //Use this code from line 12 onwards and adjust code //if you want to get a window based file selection / /*JFileChooser chooser = new JFileChooser(); fileName = chooser.getSelectedFile().toString(); chooser.showOpenDialog(null); */ c //if (chooser.getSelectedFile ()!- null) {}...
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