Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is java Each year, elementary school kids must keep track of the number of

ID: 3863799 • Letter: T

Question

This is java

Each year, elementary school kids must keep track of the number of minutes they read each week. This ensures that they continue progressing in their reading and become lifelong readers. In this program, you are to create an application that shows the sum total of the minutes read by each student. There are two files in which you are to read. The first one, Student2017.txt contains all the students. The second one, MinutesRead.txt contains the minutes read and the student id. You are to create a Student class that contains an ArrayList of all the minutes read for each student. The end user should be able to print out the individual minutes read by a student and the sum total of the minutes ready by a student. An example of output might be like this:
-----------------------------------------------------
Sum of Minutes Read
Name Minutes Read
Sammy Hagger 1,203
Nick Jonas 3,435

------------------------------------------------------
Individual Minutes Read
Name Minutes Read
Sammy Hagger 234
Sammy Hagger 345
Nick Jonas 948
Nick Jonas 232

------------------------------------------------------

students 2014

1|Claude|Camero
2|Stanley|Stewart
3|Betty|Bonsai
4|Gina|Ginger
5|Paul|Peacock

MinutesRead.txt

MinutesRead   Person
395   2
246   1
176   1
394   4
116   3
336   3
316   5
159   1
239   3
154   2
254   3
436   4
213   2
291   4
371   3
201   1
429   5
486   5
389   5
396   3
246   1
495   1
143   2
351   5
313   1
110   4
439   1
428   5
349   2
281   5
277   1
437   5
480   4
468   5
176   5
298   2
238   1
106   1
344   3
204   4
220   2
472   4
230   5
186   5
457   1
424   3
446   2
142   3
383   5
137   4
239   4
122   4
258   5
370   3
147   2
222   1
354   4
296   2
426   3
480   5
345   5
268   4
236   5
186   2
497   1
379   3
478   5
432   3
182   1
358   4
126   4
263   5
333   2
169   5
286   2
269   3
487   4
294   3
184   5
333   1
247   3
148   3
308   2
359   4
473   5
411   1
256   3
120   1
151   1
178   3
375   3
468   3
253   1
247   1
419   4
120   4
104   5
398   5
439   3
489   5
317   2
111   5
196   2
450   4
200   3
487   3
240   3
353   4
477   3
378   1
430   2
204   2
299   4
429   5
292   3
120   1
101   1
459   2
239   4
145   4
252   5
437   1
167   3
115   2
202   4
256   4
421   4
265   4
452   5
473   2
138   5
447   1
189   3
200   3
112   2
233   5
198   5
448   5
103   2
154   5
451   1
465   3
177   5
279   4
429   2
284   5
204   1
397   1
299   4
439   1
455   5
358   5
443   4
387   5
452   5
158   4
397   4
439   3
118   5
102   2
135   2
174   1
131   2
259   4
349   1
462   1
176   4
125   5
272   1
233   5
336   4
250   1
495   5
367   3
320   5
458   3
111   2
370   2
350   5

Explanation / Answer

Output

Individual Minutes Read
Stewart Stanley 395
Camero Claude 246
Camero Claude 176
Ginger Gina 394
Bonsai Betty 116
Bonsai Betty 336
Peacock Paul 316
Camero Claude 159
Bonsai Betty 239
Stewart Stanley 154
Bonsai Betty 254
Ginger Gina 436
Stewart Stanley 213
Ginger Gina 291
Bonsai Betty 371
Camero Claude 201
Peacock Paul 429
Peacock Paul 486
Peacock Paul 389
Bonsai Betty 396
Camero Claude 246
Camero Claude 495
Stewart Stanley 143
Peacock Paul 351
Camero Claude 313
Ginger Gina 110
Camero Claude 439
Peacock Paul 428
Stewart Stanley 349
Peacock Paul 281
Camero Claude 277
Peacock Paul 437
Ginger Gina 480
Peacock Paul 468
Peacock Paul 176
Stewart Stanley 298
Camero Claude 238
Camero Claude 106
Bonsai Betty 344
Ginger Gina 204
Stewart Stanley 220
Ginger Gina 472
Peacock Paul 230
Peacock Paul 186
Camero Claude 457
Bonsai Betty 424
Stewart Stanley 446
Bonsai Betty 142
Peacock Paul 383
Ginger Gina 137
Ginger Gina 239
Ginger Gina 122
Peacock Paul 258
Bonsai Betty 370
Stewart Stanley 147
Camero Claude 222
Ginger Gina 354
Stewart Stanley 296
Bonsai Betty 426
Peacock Paul 480
Peacock Paul 345
Ginger Gina 268
Peacock Paul 236
Stewart Stanley 186
Camero Claude 497
Bonsai Betty 379
Peacock Paul 478
Bonsai Betty 432
Camero Claude 182
Ginger Gina 358
Ginger Gina 126
Peacock Paul 263
Stewart Stanley 333
Peacock Paul 169
Stewart Stanley 286
Bonsai Betty 269
Ginger Gina 487
Bonsai Betty 294
Peacock Paul 184
Camero Claude 333
Bonsai Betty 247
Bonsai Betty 148
Stewart Stanley 308
Ginger Gina 359
Peacock Paul 473
Camero Claude 411
Bonsai Betty 256
Camero Claude 120
Camero Claude 151
Bonsai Betty 178
Bonsai Betty 375
Bonsai Betty 468
Camero Claude 253
Camero Claude 247
Ginger Gina 419
Ginger Gina 120
Peacock Paul 104
Peacock Paul 398
Bonsai Betty 439
Peacock Paul 489
Stewart Stanley 317
Peacock Paul 111
Stewart Stanley 196
Ginger Gina 450
Bonsai Betty 200
Bonsai Betty 487
Bonsai Betty 240
Ginger Gina 353
Bonsai Betty 477
Camero Claude 378
Stewart Stanley 430
Stewart Stanley 204
Ginger Gina 299
Peacock Paul 429
Bonsai Betty 292
Camero Claude 120
Camero Claude 101
Stewart Stanley 459
Ginger Gina 239
Ginger Gina 145
Peacock Paul 252
Camero Claude 437
Bonsai Betty 167
Stewart Stanley 115
Ginger Gina 202
Ginger Gina 256
Ginger Gina 421
Ginger Gina 265
Peacock Paul 452
Stewart Stanley 473
Peacock Paul 138
Camero Claude 447
Bonsai Betty 189
Bonsai Betty 200
Stewart Stanley 112
Peacock Paul 233
Peacock Paul 198
Peacock Paul 448
Stewart Stanley 103
Peacock Paul 154
Camero Claude 451
Bonsai Betty 465
Peacock Paul 177
Ginger Gina 279
Stewart Stanley 429
Peacock Paul 284
Camero Claude 204
Camero Claude 397
Ginger Gina 299
Camero Claude 439
Peacock Paul 455
Peacock Paul 358
Ginger Gina 443
Peacock Paul 387
Peacock Paul 452
Ginger Gina 158
Ginger Gina 397
Bonsai Betty 439
Peacock Paul 118
Stewart Stanley 102
Stewart Stanley 135
Camero Claude 174
Stewart Stanley 131
Ginger Gina 259
Camero Claude 349
Camero Claude 462
Ginger Gina 176
Peacock Paul 125
Camero Claude 272
Peacock Paul 233
Ginger Gina 336
Camero Claude 250
Peacock Paul 495
Bonsai Betty 367
Peacock Paul 320
Bonsai Betty 458
Stewart Stanley 111
Stewart Stanley 370
Peacock Paul 350

Sum of Minutes Read
Camero Claude 10250
Stewart Stanley 7461
Bonsai Betty 10884
Ginger Gina 10353
Peacock Paul 14606

Program

Student.java

import java.util.ArrayList;

public class Student {
   ArrayList<Integer> minutesRead=null;
   public ArrayList<Integer> getList()
   {
       if(minutesRead==null)
           minutesRead=new ArrayList<>();
       return minutesRead;
   }
  
}

Main.java

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Main {

   static HashMap<Integer, Student> map = new HashMap<>();
   static HashMap<Integer, String> names = new HashMap<>();

   public static void main(String[] args) {
       // Reading Student Names
       BufferedReader br = null;
       FileReader fr = null;

       try {

           fr = new FileReader("Student2017.txt");
           br = new BufferedReader(fr);
           String sCurrentLine;
           br = new BufferedReader(new FileReader("Student2017.txt"));
           while ((sCurrentLine = br.readLine()) != null) {
               String sp[]=sCurrentLine.split("\W");
               int id=Integer.valueOf(sp[0]);
               String name=sp[2]+" "+sp[1];
               names.put(id, name);
               //System.out.println(id+ " "+name);
           }
           br.close();
           fr.close();
          
           //Reading Values
           fr = new FileReader("MinutesRead.txt");
           br = new BufferedReader(fr);
           br = new BufferedReader(new FileReader("MinutesRead.txt"));
           System.out.println("Individual Minutes Read");
           while ((sCurrentLine = br.readLine()) != null) {
               String sp[]=sCurrentLine.split("\W");
               int id=Integer.parseInt(sp[sp.length-1]);
               int value=Integer.parseInt(sp[0]);
               System.out.println(names.get(id) + " " + value);
               if(map.containsKey(id))
               {
                   map.get(id).getList().add(value);
               }
               else
               {
                   Student s=new Student();
                   s.getList().add(value);
                   map.put(id, s);
               }
              
           }
          
          
           //Printing Individual Values
           System.out.println(" Sum of Minutes Read");
           Iterator it = map.entrySet().iterator();
       while (it.hasNext()) {
       Map.Entry pair = (Map.Entry)it.next();
       Iterator<Integer> iter=((Student)pair.getValue()).getList().iterator();
       int sum=0;
       while(iter.hasNext())
       {
           sum+=iter.next();
       }
       System.out.println(names.get(pair.getKey()) + " " + sum);
       }
       } catch (IOException e) {

           e.printStackTrace();

       } finally {

           try {

               if (br != null)
                   br.close();

               if (fr != null)
                   fr.close();

           } catch (IOException ex) {

               ex.printStackTrace();

           }

       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote