Question: Write a Java program that does the following jobs. Step1. Creates a Car table with car manufacturers, models, fuel efficiency (MPG), and price. Step2. Reads

Write a Java program that does the following jobs.

Step1. Creates a Car table with car manufacturers, models, fuel efficiency (MPG), and price.

Step2. Reads data from a text file and insert the cars to the table created in Step 1.

Step3. Interact with the user, where the user can select one of the following actions.

- (Q) Quit: quit the program

- (A) Add a car: insert a car to the table

- (C) Calculate avg: calculate the average MPG

- (W) Write the entire table to a text file

- (P) Print the entire table

- (M) Print a subset of the cars based on the price (ex. Print cars with price <= 25000)

The user can choose one of these actions with typing Q,A,C, W, P, or M in the console. When adding a car, the user must provide manufacturer, model, mpg, and price through the console. When writing the table to a text file, the user must provide output text file name. When selecting a subset of the cars based on price, an upper bound price value must be provided.

Four files are provided with the assignment:

1. CarDB.java: the main class of this assignment. -- https://ufile.io/mqt3h

2. Database.properties: file for Apache Derby -- https://ufile.io/r12y8

3. SimpleDataSource.java: file for Apache Derby -- https://ufile.io/qk7wi

4. Carmpg.txt: sample text file for Step 2. -- https://ufile.io/4iauf

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!