Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

The attached text file lists all vehicles entered to the parking lot of a mega shopping centre for one day. Each line of the text file includes a vehicle make, color, plate number and the date of entry to the mall. Based on the content of this text file and the program result in the console, provide a line-by-line description for the below java program. 

Please provide line by line explaination for the code below. And I don't understand line 16, so detail that a bit.

Pr...
✓ Exercise 09
> .idea
out
src
Run:
✓ Exercise09Class.java
Cars
> Illi External Libraries
↑
& ↓
Exercise09Class
Ⓒ Parking Lot
Exercise09.iml
logfile.txt
>>
✿
Scratches and Consoles
Toyota
BDKK-863
Green
Version Control
▶ Run
2
3
4
5
6
7 ►
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Exercise09Class.java
30
31
32
33
34
35
36
B
Exercise09Class
Mon Feb 24 09:00:40 EST 2020
B
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Date;
public class Exercise09Class {
public static void main(String[] args) {
try {
TODO e Problems
File text = new File( pathname: "logfile.txt");
Scanner input = new Scanner (text);
Parking Lot parkingCars=new Parking Lot ();
int countLines=0;
}
while(input.hasNextLine()) {
}
String line = input.nextLine();
Date dd=strToDate (line.substring(29,33).trim(), line.substring(35,37).trim(), line.substring(37,39).trim(),
line.substring(40, 42).trim(), line.substring(43, 45).trim(), line.substring(46, 48).trim());
parkingCars.addCar (dd, Line.substring(1, 10).trim(), line.substring(11,19).trim(), line.substring(20, 28).trim());
countLines++;
System.out.println(countLines);
System.out.println (parkingCars.cars.get (2).dateIn);
System.out.println (parkingCars.cars.get (3).make);
System.out.println (parkingCars.cars.get(0).plate);
System.out.println (parkingCars.cars.get(1).color);
} catch (Exception e) {
System.out.println("Something is wrong in reading the text file, OR in converting the string to date!");
}
1 usage
public static Date strToDate(String year, String month, String day, String hour, String minute, String second)
throws ParseException {
String dateStr =""+day+"/"+month+"/"+year+" "+hour+":"+minute+": "+second;
SimpleDateFormat frmt=new SimpleDateFormat( pattern: "dd/MM/yyyy HH:mm:ss");
return frmt.parse(dateStr);
Terminal ▸ Services
Build
expand button
Transcribed Image Text:Pr... ✓ Exercise 09 > .idea out src Run: ✓ Exercise09Class.java Cars > Illi External Libraries ↑ & ↓ Exercise09Class Ⓒ Parking Lot Exercise09.iml logfile.txt >> ✿ Scratches and Consoles Toyota BDKK-863 Green Version Control ▶ Run 2 3 4 5 6 7 ► 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Exercise09Class.java 30 31 32 33 34 35 36 B Exercise09Class Mon Feb 24 09:00:40 EST 2020 B import java.io.File; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Scanner; import java.util.Date; public class Exercise09Class { public static void main(String[] args) { try { TODO e Problems File text = new File( pathname: "logfile.txt"); Scanner input = new Scanner (text); Parking Lot parkingCars=new Parking Lot (); int countLines=0; } while(input.hasNextLine()) { } String line = input.nextLine(); Date dd=strToDate (line.substring(29,33).trim(), line.substring(35,37).trim(), line.substring(37,39).trim(), line.substring(40, 42).trim(), line.substring(43, 45).trim(), line.substring(46, 48).trim()); parkingCars.addCar (dd, Line.substring(1, 10).trim(), line.substring(11,19).trim(), line.substring(20, 28).trim()); countLines++; System.out.println(countLines); System.out.println (parkingCars.cars.get (2).dateIn); System.out.println (parkingCars.cars.get (3).make); System.out.println (parkingCars.cars.get(0).plate); System.out.println (parkingCars.cars.get(1).color); } catch (Exception e) { System.out.println("Something is wrong in reading the text file, OR in converting the string to date!"); } 1 usage public static Date strToDate(String year, String month, String day, String hour, String minute, String second) throws ParseException { String dateStr =""+day+"/"+month+"/"+year+" "+hour+":"+minute+": "+second; SimpleDateFormat frmt=new SimpleDateFormat( pattern: "dd/MM/yyyy HH:mm:ss"); return frmt.parse(dateStr); Terminal ▸ Services Build
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY