Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. //add your header comments here
  5.  
  6. class Driver2 {
  7. public static void main (String[] args) throws IOException {
  8. File inputFile = new File ("records.txt");
  9. Scanner sc = new Scanner(inputFile);
  10. String orderDate, region, customer, item;
  11. String[] filter = {"pencil", "Binder", "Pen", "Pen Set", "Desk", "ALL"};
  12. int units;
  13. double cost, total, grandTotal;
  14.  
  15. grandTotal = 0;
  16. while (sc.hasNextLine()) {
  17. String[] split = sc.nextLine().split("t");
  18. orderDate = split[0];
  19. region = split[1];
  20. customer = split[2];
  21. item = split[3];
  22. if(item != filter[0]){
  23.  
  24. }else{
  25. units = Integer.parseInt(split[4]);
  26. cost = Double.parseDouble(split[5]);
  27. total = Double.parseDouble(split[6]);
  28.  
  29. grandTotal = grandTotal + total;
  30. System.out.printf("%-10s%-9s", orderDate, region);
  31. System.out.printf("%-10s", customer);
  32. System.out.printf("%-8s%4d", item, units);
  33. System.out.printf("%10.2f%10.2f%n", cost, total);
  34. }
  35. }
  36. System.out.printf("%nThe sum total = $%.2f%n%n", grandTotal);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement