Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how can do this program in java: 1- The file presidents.txt is a text le that contains each president's name on one line followed by

how can do this program in java:

1- The file presidents.txt is a text le that contains each president's name on one line followed by three integers on the next line indicating the month, day and year of their birth. Write a program that asks the user for a month, then opens this file and outputs all of the presidents born on that month to both the screen and to another file. This new file should be called presidents.txt where is the number of the month entered (for example, if 6 was entered for the month, then you should output the results to a file names presidents6.txt.

2- The file presidents.dat contains the same info as presidents.txt but now stored in a binary file. Write the same program as above but now using the binary file. Your output file should also be a binary file.

3- There are several ways to sort the data in the presidents.txt file, two of which are by last name and by date of birth. This problem will investigate one way to allow the user to easily sort by either field. (a) Create a President class which contains fields to store the name and birth date of a President (you can just use three int fields for the birth date). In addition, add a static field named sortBy and two static constants LASTNAME and BIRTHDATE. Add a method to allow the user to set the sortBy field to either of these constants. (b) Now modify the President class so that it implements the Comparable interface. The compareTo method should make use of the sortBy field. (c) Now write a driver program that opens the president.txt le, asks the user how they want the information sorted, and then sorts the data appropriately using Insertion Sort and writes it to the presidents_sorted.txt file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. What are the current trends in computer software platforms?

Answered: 1 week ago