Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Project 2: Deduplication Write a program that reads a file of numbers of type int and outputs all of those numbers to another file,

JAVA Project 2: Deduplication

Write a program that reads a file of numbers of type int and outputs all of those numbers to another file, but without any duplicate numbers. You should assume that the input file is sorted from smallest to largest with one number on each line. After the program is run, the output file should contain all numbers that are in the original file, but no number should appear more than once. The numbers in the output file should also be sorted from smallest to largest with one number on each line.

Your program should not assume that there is a fixed number of entries to be read, but should be able to work with any number of entries in both the input and output files.

This means that you should not use arrays.

Arrays have a fixed size. Instead, your program should read in and write out numbers from the input and output files at the same time, eliminating duplicates from the output file as you go.

Your program should obtain both file names from the user. For the original (input) file, create a text file that stores one number per line with several duplicates in sorted order. The output file should be created by your program. When completed, your program should display a count of numbers in the input file, a count of the numbers in the output file, and the number of duplicates on the screen.

Submit program files for all classes, copies of your input and output text files, and a PrintScreen of the console output when your program is run.

Example:

 Input File Output File Contents Contents  1 1  3 3  3 60  3 75  60 80  60 100  75 130  75 140  75 985  80 1000  80 100  130  140  985  985  985  1000

Sample console dialog, where input from the user is underlined in italics

 Enter input file name or full path: numbers.txt  Enter output file name or full path: output.txt  There were 18 numbers input, 10 output, and 8 duplicates. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions