0% found this document useful (0 votes)
9 views4 pages

Java Car Driving Simulator Program

The program simulates driving cars from data in a file by creating Car objects and displaying messages for each one. It checks if the required file exists and handles if it is missing before ending.

Uploaded by

hbg55psg9g
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Java Car Driving Simulator Program

The program simulates driving cars from data in a file by creating Car objects and displaying messages for each one. It checks if the required file exists and handles if it is missing before ending.

Uploaded by

hbg55psg9g
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Car Driving Simulator Program

The "Car Driving Simulator Program" is a Java application designed to


simulate driving various cars based on data stored in a text file named
"[Link]". The program utilizes object-oriented programming concepts such as
classes, objects, and methods to model cars and their driving behavior. It also
incorporates file input/output operations for reading data from the text file.

Upon execution, the program checks if the file "[Link]" exists. If the file
is found, it reads the data and creates Car objects for each line in the file. For each
Car object, the program simulates driving by displaying a message indicating the
brand and model of the car being driven. If the file is not found, the program
notifies the user with a "File not found" message.

Overall, the Car Driving Simulator Program provides a simple yet illustrative
example of how to implement object-oriented concepts, file input/output
operations, and basic exception handling in Java. It can be used for educational
purposes to understand Java programming fundamentals and concepts such as
classes, objects, methods, inheritance, and exception handling, as well as file
input/output operations.

Members:
1. Auguis, John Leodrick
2. Benedicto, Jhunard June
3. Biadan, Wesel Nicolai
4. Lingcon, Reavin
5. Lumanta, Jovien
6. Ronquillo, Junero Charls
Flowchart:

Start

Check if
"[Link]" exists

If file exists:

Read data from file

For each line in file:

Split data into brand and model

Create Car object

Drive the Car

If file doesn't exist:

Display "File not found"

End
Program Flow Narrative:

1. Start:
 The program begins execution.
2. Check File Existence:
 It checks if the file "[Link]" exists.
3. File Existence Decision:
 If the file exists:
- It reads data from the file.
- For each line in the file:
- It splits the data into brand and model.
- Creates a Car object with the extracted brand and model.
- Drives the Car.
 If the file doesn't exist:
- It displays "File not found" message.
4. End:
 The program ends.

Sample Outputs:

You might also like