Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- //add your header comments here
- class Driver2 {
- public static void main (String[] args) throws IOException {
- File inputFile = new File ("records.txt");
- Scanner sc = new Scanner(inputFile);
- String orderDate, region, customer, item;
- String[] filter = {"pencil", "Binder", "Pen", "Pen Set", "Desk", "ALL"};
- int units;
- double cost, total, grandTotal;
- grandTotal = 0;
- while (sc.hasNextLine()) {
- String[] split = sc.nextLine().split("t");
- orderDate = split[0];
- region = split[1];
- customer = split[2];
- item = split[3];
- if(item != filter[0]){
- }else{
- units = Integer.parseInt(split[4]);
- cost = Double.parseDouble(split[5]);
- total = Double.parseDouble(split[6]);
- grandTotal = grandTotal + total;
- System.out.printf("%-10s%-9s", orderDate, region);
- System.out.printf("%-10s", customer);
- System.out.printf("%-8s%4d", item, units);
- System.out.printf("%10.2f%10.2f%n", cost, total);
- }
- }
- System.out.printf("%nThe sum total = $%.2f%n%n", grandTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement