Create a program that reads a list of names from a source file and writes those names to a CSV file.
Name your class LoopsFiles
Create a program that reads a list of names from a source file and writes those names to a CSV file.
The source file name and target CSV file name should be requested from the user
The source file can have a variable number of names so your program should be dynamic enough to read as many names as needed
When writing your CSV file, the first row (header row) should be “Number, Name”.
The final CSV should have the header row and a row with the sequential number, name read.
The program should display an error message if the source file doesn’t exist.
If the destination file exists the program should warn the user and prompt the user if they want to overwrite the existing file (Y/N).
The user should be prompted until they enter Y for yes to overwrite, or enter a unique name after answering N for the overwrite prompt.
Submit your single .java file
Source file example:
John
Peter
Jane
Mary
Evelyn
Daniel
New CSV File example:
Number, Name
1,John
2,Peter
3,Jane
4,Mary
5,Evelyn
6,Daniel
Example Scenario 1 – Normal run:
Enter source file name: source.txt
Enter destination file name: destination.csv
Your file is ready!
Example Scenario 2 – File doesn’t exist:
Enter source file name: source.txt
Enter destination file name: destination.csv
Source file doesn’t exist!
Example Scenario 3 – Target file already exists (overwrite):
Enter source file name: source.txt
Enter destination file name: destination.csv
Target file already exists. Overwrite existing file? (Y/N): N
Enter destination file name: destination.csv
Target file already exists. Overwrite existing file? (Y/N): N
Enter destination file name: destination.csv
Target file already exists. Overwrite existing file? (Y/N): N
Enter destination file name: destination.csv
Target file already exists. Overwrite existing file? (Y/N): Y
Your file is ready!
Example Scenario 4 – Target file already exists (new name given):
Enter source file name: source.txt
Enter destination file name: destination.csv
Target file already exists. Overwrite existing file? (Y/N): N
Enter destination file name: destination.csv
Target file already exists. Overwrite existing file? (Y/N): N
Enter destination file name: destination2.csv
Your file is ready!
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.