When submitting this lab, submit a .java file called FormLetter, and create the following structure in Eclipse: Write a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

When submitting this lab, submit a .java file called FormLetter, and create the following structure in Eclipse: Write a

Post by answerhappygod »

When submitting this lab, submit a .java file called FormLetter,and create the following structure in Eclipse:
Write a program that will read a CSV file containing scores forstudent assignments, and create a letter saved to a file for eachstudent who has one or more scores of 0, and then print outmessages to the console indicating which students have letterswritten (as show in the example run). In this program you willcombine data from the CSV file and the TXT file to create a letterto each student in the class who is missing one or moreassignments. The letter must have the following format:
<student name>,
<text from Warning Letter to Student - .txt file>
<list of missing assignments>
Each letter file must be saved with the following namingformat:
Warning letter to student - <student name>.txt
Downloads
For this lab you will need to download the file StudentAssignment Scores.csv DownloadStudent Assignment Scores.csv. This file contains a list ofstudents and the scores they received for 6 class assignments.Place this file in your PROJECT directory. You will also needto download the file Warning Letter to Students-.txt DownloadWarning Letter to Students -.txt. This file contains the body of aform letter to students who are missing assignments. Place thisfile in your PROJECT directory.
Steps
Reading an entire file into a String Variable
The Scanner has several different methods you are not fullyfamiliar with.
By setting the delimiter to a value you know is not foundanywhere in an input file, and then calling .next(), you cansuccessfully read the entire contents of a file into a Stringvariable.
Example:
Scanner letter = new Scanner(letterFile); //Create a new Scanner object (letter)that points to a File.
letter.useDelimiter("\\Z"); //Change the delimiter of the letter Scanner object to "\\Z" sinceyou know that the string "\\Z" is not found anywhere in your .txtfile.
String letterBody = letter.next(); // .next() will read the entire contents of thefile since the delimiter "\\Z" is not found in the .txt file. The String letterBody now contains the entire contents of thefile.
Example Run
Your program output should look like this:
Creating letters for:
Garrett WangEthan PhillipsRoxann DawsonRobert BeltranRobert McNeilArmin ShimermanDominic KeatingJohn Billings
Before you run your program, your directory should looklike this:
After you run your program, your directory should look likethis:
Opening one of the sample letter files in a document editorshould look like this:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply