Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. int id;
  2. String content = "";
  3. NumberFormat formatter = NumberFormat.getCurrencyInstance();
  4. for(int x=1;x<=numoforder;x++){
  5. //single thread
  6. file=new BufferedReader(new FileReader(base+x+".txt"));
  7.  
  8. //read the data file
  9. try{
  10. String data;
  11.  
  12. data=file.readLine();
  13. count=new HashMap<String,Integer>();
  14. for(String n: prices.keySet()){
  15. count.put(n, 0);
  16. }
  17. //client id
  18. id=Integer.parseInt((data.split(" ")[1]));
  19. System.out.println("Reading order for client with id: "+id);
  20. //output processing for client id
  21.  
  22. //clients purchases
  23. while((data=file.readLine())!=null)
  24. {
  25. String name=data.split(" ")[0];
  26. count.put(name,count.get(name)+1);
  27. summarymap.put(name,summarymap.get(name)+1);
  28. }
  29. file.close();
  30.  
  31. content += "----- Order details for client with Id:"+id + " -----n";
  32.  
  33. //
  34. List<String>temp=new ArrayList<String>(prices.keySet());
  35. Collections.sort(temp);
  36. double cout=0;
  37. double total = 0;
  38. for(String key:temp)
  39. {
  40. if(count.get(key)==0)
  41. {
  42.  
  43. }
  44. else{
  45.  
  46. content += "Item's name: " + key +", Cost per item: "+formatter.format(prices.get(key)) +","+" Quantity: "+ count.get(key)+","+
  47. " Cost: "+formatter.format((prices.get(key))*count.get(key))+"n";
  48. total+=((prices.get(key))*count.get(key));
  49.  
  50.  
  51. }
  52.  
  53. }
  54. content+="Order Total: "+formatter.format(total)+"n";
  55.  
  56. }
  57.  
  58. catch (IOException e){
  59.  
  60. e.printStackTrace();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement