Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int id;
- String content = "";
- NumberFormat formatter = NumberFormat.getCurrencyInstance();
- for(int x=1;x<=numoforder;x++){
- //single thread
- file=new BufferedReader(new FileReader(base+x+".txt"));
- //read the data file
- try{
- String data;
- data=file.readLine();
- count=new HashMap<String,Integer>();
- for(String n: prices.keySet()){
- count.put(n, 0);
- }
- //client id
- id=Integer.parseInt((data.split(" ")[1]));
- System.out.println("Reading order for client with id: "+id);
- //output processing for client id
- //clients purchases
- while((data=file.readLine())!=null)
- {
- String name=data.split(" ")[0];
- count.put(name,count.get(name)+1);
- summarymap.put(name,summarymap.get(name)+1);
- }
- file.close();
- content += "----- Order details for client with Id:"+id + " -----n";
- //
- List<String>temp=new ArrayList<String>(prices.keySet());
- Collections.sort(temp);
- double cout=0;
- double total = 0;
- for(String key:temp)
- {
- if(count.get(key)==0)
- {
- }
- else{
- content += "Item's name: " + key +", Cost per item: "+formatter.format(prices.get(key)) +","+" Quantity: "+ count.get(key)+","+
- " Cost: "+formatter.format((prices.get(key))*count.get(key))+"n";
- total+=((prices.get(key))*count.get(key));
- }
- }
- content+="Order Total: "+formatter.format(total)+"n";
- }
- catch (IOException e){
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement