ase provide line by line explaination for the code below. And I don't understand line 16, so detail that a
ase provide line by line explaination for the code below. And I don't understand line 16, so detail that a
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd0de0f8a-cbae-4106-98d2-7bea7a49e126%2F0681029f-389d-4a23-a371-a350bc4d521f%2Fy3tkj03_processed.png&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY