Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

The Car Class

Define a class called "Car" that implements the parameterized Comparable interface. Each object of this class represents a type of car. Your class must provide all the methods in the public interface. Be sure to properly document each method in this class.

The CarComparator Class

Define a class, "CarComparator", that implements the parameterized Comparator interface. The Compare method should compare cars by -year+make+model, where + denotes ascending order, - denotes descending order, and year, make and model are the primary, secondary and tertiary keys.

The CarSorter Class

Write a program, CarSorter, to test your Car and

CarComparator implementations. Suppose that you have a text file with each line containing the year, an integer, the make, a one-word string, and model, a string of one or more words, of a car. Write a program that reads the information about the cars from the file and stores them in an array list of objects of the Car class.

For example, the input file to the program could be carlot.txt whose contents are shown below:

1998 Honda Prelude

1998 Honda Accord

2006 Honda Ridgeline

1996 Ford Taurus

1996 Mitsubishi Eclipse

2015 Mitsubishi Galant

2010 Ford Fusion

2003 Mazda Protege 5

2002 Mazda Protege 5

2002 Isuzu Trooper

Your program should do the following:

1. prompt the user for the name of the input file,

2. read the data from the input file and store information about the cars in an array list of Car objects,

3. print the unsorted data from the array list to the screen, as shown below,

4. create another array list and an array that contain the same data as the original array list,

5. sort the second array list by the order defined by the Comparable interface, while leaving the original array list unsorted

6. prompt the user for the name of an output file and then display on the screen and write the information in the sorted array list to the file,

7. sort the array by the order defined by the Comparable interface,

8. prompt the user for the name of a second output file and then display on the screen and write the information in the sorted array to the file,

9. again, create a third array list and a second array that contain the same data as the original array list,

10. sort the third array list using a comparator of the CarComparator class,

11. prompt the user for the name of third output file and then display on the screen and write the information in the sorted array list to the file,

12. sort the second array using a comparator of the CarComparator class,

13. and, finally, prompt the user for the name of a fourth output file and then display on the screen and write the information in the sorted array to the file.

The input file may contain information about any number of cars. The output to the file and on the screen should be formatted as shown in the sample run below. Your program should use a try-catch statement to handle any potential IOException.

Enter the name of the input file -> carlot.txt

The Unsorted Array List of Cars

[Honda, Prelude, 1998]

[Honda, Accord, 1998]

[Honda, Ridgeline, 2006]

[Ford, Taurus, 1996]

[Mitsubishi, Eclipse, 1996]

[Mitsubishi, Galant, 2015]

[Ford, Fusion, 2010]

[Mazda, Protege 5, 2003]

[Mazda, Protege 5, 2002]

[Isuzu, Trooper, 2002]

Enter the name of the first output file -> mmya1.txt

The Sorted Array List of Cars By Make-Model-Year

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

Ford Fusion 2010

Ford Taurus 1996

Honda Accord 1998

Honda Prelude 1998

Honda Ridgeline 2006

Isuzu Trooper 2002

Mazda Protege 5 2002

Mazda Protege 5 2003

Mitsubishi Eclipse 1996

Mitsubishi Galant 2015

Enter the name of the second output file -> mmya.txt

The Sorted Array of Cars By Make-Model-Year

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

Ford Fusion 2010

Ford Taurus 1996

Honda Accord 1998

Honda Prelude 1998

Honda Ridgeline 2006

Isuzu Trooper 2002

Mazda Protege 5 2002

Mazda Protege 5 2003

Mitsubishi Eclipse 1996

Mitsubishi Galant 2015

Enter the name of the third output file -> ymmal.txt

The Sorted Array List of Cars By Year-Make-Model

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

2015 Mitsubishi Galant

2010 Ford Fusion

2006 Honda Ridgeline

2003 Mazda Protege 5

2002 Isuzu Trooper

2002 Mazda Protege 5

1998 Honda Accord

1998 Honda Prelude

1996 Ford Taurus

1996 Mitsubishi Eclipse

Enter the name of the fourth output file -> ymma.txt

The Sorted Array of Cars By Year-Make-Model

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

2015 Mitsubishi Galant

2010 Ford Fusion

2006 Honda Ridgeline

2003 Mazda Protege 5

2002 Isuzu Trooper

2002 Mazda Protege 5

1998 Honda Accord

1998 Honda Prelude

1996 Ford Taurus

1996 Mitsubishi Eclipse.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92064798
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Programming Language

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As