Write a program that reads a CSV file, sorts a list of integers on each row, and prints a comma separated list of sorted integers on the console. The program should prompt the user to enter a file name, then should open the file in text mode and read. Input files are assumed to be in CSV format. Input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together on a single line on the console (see below for test cases). While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name. If a file with a given name exists, then your program should process it, should print the results and exit. On each line the input file may contain any number of integers. You may use arrays or ArrayList objects in your program. You may choose to use any of the sorting algorithms (provided in a class file called “Sort.java” for your convenience). All sorting methods work with arrays as well as ArrayLists. Sort.java file is already uploaded and you don’t need to upload it again with your submission. You should only upload one file: FileSorting.java. You can download the Sort.java file and use it on your computer for testing your program. Input validation: a) If the file does not exist, then you should display a message "File somefile.txt is not found." and allow the user to re-enter the file name. b) If the file is empty, then display a message "File somefile.txt is empty." and exit the program. Hints: a) Perform file name input validation immediately after the user entry and use a while loop. b) You can use either StringTokenizer class or String.split() method to separate each line into tokens. It’s also possible to use a string Scanner, if you know how to do it. c) All tokenization methods mentioned above will give you strings. You will need to sort the array or ArrayList as numbers, so you need to do a conversion from string array (or ArrayList) into an integer array (or ArrayList). d) For each line, create an array of integers and populate with the numbers from that line. e) Use either one of the Sort.insertionSort(), Sort.selectionSort (), or Sort.bubbleSort () methods to sort integers. f) If you know how to use String.join() or Arrays.sort() methods, feel free to use them, but you don’t have to use them. Grading guide: 1. Functionality: Does the program work and perform basic functionality as per requirements? (Need to be able to compile and run the program with some input and some output): 40% 2. Correctness: Does the program properly sort numbers? Does the program read and display all required lines? - 20% 3. Input Validation: Is the user input validated against requirements? - 20% 4. Output Formatting: Is the output formatted according to the requirements: 10% 5. Edge Cases: Does the program work without errors for ALL values of input (missing file, empty file, odd or even number of lines, very large file, etc.) - 10%   input2x2.csv -67,-11 -27,-70 input1.csv 10 input10x10.csv 56,-19,-21,-51,45,96,-46 -27,29,-58,85,8,71,34 50,51,40,50,100,-82,-87 -47,-24,-27,-32,-25,46,88 -47,95,-41,-75,85,-16,43 -78,0,94,-77,-69,78,-25 -80,-31,-95,82,-86,-32,-22 68,-52,-4,-68,10,-14,-89 26,33,-59,-51,-48,-34,-52 -47,-24,80,16,80,-66,-42 input0.csv     Test Case 1             Please enter the file name or type QUIT to exit:\n input1.csvENTER 10\n   Test Case 2             Please enter the file name or type QUIT to exit:\n input2x2.csvENTER -67,-11\n -70,-27\n   Test Case 3             Please enter the file name or type QUIT to exit:\n input10x10.csvENTER -51,-46,-21,-19,45,56,96\n -58,-27,8,29,34,71,85\n -87,-82,40,50,50,51,100\n -47,-32,-27,-25,-24,46,88\n -75,-47,-41,-16,43,85,95\n -78,-77,-69,-25,0,78,94\n -95,-86,-80,-32,-31,-22,82\n -89,-68,-52,-14,-4,10,68\n -59,-52,-51,-48,-34,26,33\n -66,-47,-42,-24,16,80,80\n   Test Case 4             Please enter the file name or type QUIT to exit:\n input0.csvENTER File input0.csv is empty.\n   Test Case 5             Please enter the file name or type QUIT to exit:\n input2.csvENTER File input2.csv is not found.\n Please re-enter the file name or type QUIT to exit:\n input1.csvENTER 10\n   Test Case 6             Please enter the file name or type QUIT to exit:\n quitENTER   Test Case 7             Please enter the file name or type QUIT to exit:\n input2.csvENTER File input2.csv is not found.\n Please re-enter the file name or type QUIT to exit:\n QUITENTER

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
 
 
Write a program that reads a CSV file, sorts a list of integers on each row, and prints a comma separated list of sorted integers on the console.
The program should prompt the user to enter a file name, then should open the file in text mode and read. Input files are assumed to be in CSV format. Input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together on a single line on the console (see below for test cases).
While entering the file name, the program should allow the user to type quit to exit the program.
If the file with a given name does not exist, then display a message and allow the user to re-enter the file name.
If a file with a given name exists, then your program should process it, should print the results and exit.
On each line the input file may contain any number of integers. You may use arrays or ArrayList objects in your program.
You may choose to use any of the sorting algorithms (provided in a class file called “Sort.java” for your convenience). All sorting methods work with arrays as well as ArrayLists. Sort.java file is already uploaded and you don’t need to upload it again with your submission. You should only upload one file: FileSorting.java. You can download the Sort.java file and use it on your computer for testing your program.
Input validation:
a) If the file does not exist, then you should display a message "File somefile.txt is not found." and allow the user to re-enter the file name.
b) If the file is empty, then display a message "File somefile.txt is empty." and exit the program.
Hints:
a) Perform file name input validation immediately after the user entry and use a while loop.
b) You can use either StringTokenizer class or String.split() method to separate each line into tokens. It’s also possible to use a string Scanner, if you know how to do it.
c) All tokenization methods mentioned above will give you strings. You will need to sort the array or ArrayList as numbers, so you need to do a conversion from string array (or ArrayList) into an integer array (or ArrayList).
d) For each line, create an array of integers and populate with the numbers from that line.
e) Use either one of the Sort.insertionSort(), Sort.selectionSort (), or Sort.bubbleSort () methods to sort integers.
f) If you know how to use String.join() or Arrays.sort() methods, feel free to use them, but you don’t have to use them.
Grading guide:
1. Functionality: Does the program work and perform basic functionality as per requirements? (Need to be able to compile and run the program with some input and some output): 40%
2. Correctness: Does the program properly sort numbers? Does the program read and display all required lines? - 20%
3. Input Validation: Is the user input validated against requirements? - 20%
4. Output Formatting: Is the output formatted according to the requirements: 10%
5. Edge Cases: Does the program work without errors for ALL values of input (missing file, empty file, odd or even number of lines, very large file, etc.) - 10%
 

input2x2.csv

-67,-11
-27,-70

input1.csv
10

input10x10.csv
56,-19,-21,-51,45,96,-46
-27,29,-58,85,8,71,34
50,51,40,50,100,-82,-87
-47,-24,-27,-32,-25,46,88
-47,95,-41,-75,85,-16,43
-78,0,94,-77,-69,78,-25
-80,-31,-95,82,-86,-32,-22
68,-52,-4,-68,10,-14,-89
26,33,-59,-51,-48,-34,-52
-47,-24,80,16,80,-66,-42

input0.csv

 

 

Test Case 1

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
input1.csvENTER
10\n
 

Test Case 2

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
input2x2.csvENTER
-67,-11\n
-70,-27\n
 

Test Case 3

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
input10x10.csvENTER
-51,-46,-21,-19,45,56,96\n
-58,-27,8,29,34,71,85\n
-87,-82,40,50,50,51,100\n
-47,-32,-27,-25,-24,46,88\n
-75,-47,-41,-16,43,85,95\n
-78,-77,-69,-25,0,78,94\n
-95,-86,-80,-32,-31,-22,82\n
-89,-68,-52,-14,-4,10,68\n
-59,-52,-51,-48,-34,26,33\n
-66,-47,-42,-24,16,80,80\n
 

Test Case 4

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
input0.csvENTER
File input0.csv is empty.\n
 

Test Case 5

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
input2.csvENTER
File input2.csv is not found.\n
Please re-enter the file name or type QUIT to exit:\n
input1.csvENTER
10\n
 

Test Case 6

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
quitENTER
 

Test Case 7

 
 
 
 
 
 
Please enter the file name or type QUIT to exit:\n
input2.csvENTER
File input2.csv is not found.\n
Please re-enter the file name or type QUIT to exit:\n
QUITENTER
 
 
Expert Solution
steps

Step by step

Solved in 4 steps with 8 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education