CISS-110 Project 5
This project deals with EOF-based loops, using the while
construct where we do not know the exact number of times a loop will iterate (perform the associated block of code). We will continue to build on our knowledge of if/else
constructs and introduce the idea of nested loops.
Learning outcomes
- Implementing EOF loops.
- Optional: Using nested loops.
- Working with files.
- Using
Scanner
with files. - Optional: Using
Scanner
with strings. - Confirmation program produces desired results.
You will work with two files:
Scanner inFile = new Scanner(new FileReader("input.txt"));
PrintWriter outFile = new PrintWriter("output.txt");
For each version of the project, use the following text as provided:
A frosted glass plate rested amidst the bottles, glasses, cups and saucers upon the table. For so many dishes, they held practically no food, save one plate. The plate was made of ordinary green glass and was likely kept in the refrigerated unit of the Garde Manger station beyond the swaying hinged door, well within the realm of the kitchen. The contents of the plate: a variety of leafy greens, sliced radish, carrot, celery, pepperoncini and pickled beet. This plate and its colorful bounty were now on display at the table for all to see. In fact, the only form of true sustenance at this table was upon this plate. "That's a very colorful salad you have there, Michael," said Shannon. She was seated to Michael's right at the table of five who were gathered around the six-top. Shannon was petite, but strong, with long, curly auburn hair and pale, freckled skin. "Yes, Michael. Very artistic choice this fine Saturday night," quipped Peter and he gave a genuine, but jovial smile. Peter was seated on Michael's left, dressed in a business suit, clean cut with slightly obvious chiseled features. Jason sat on the opposite side of Peter. He scowled and offered, "That's a rather lame dinner, if you ask me." "Which I didn't," answered Michael and added, "but your stunning choice of liquid entree has not gone unnoticed." Jason raised his glass of single-malt scotch and announced, "Alcohol! Because no great story ever started with someone eating a salad."
Contents of input.txt
.
You have two choices for this project:
- Version A of the project has you read lines from the file. With each line you will
- Get each word from the line.
- With each word, capitalize the first letter.
- Write the words to the output file in such a way that you preserve the general layout of the original.
- Report to the user the total number of words and lines.
- Version B of the project has you read words from the file. With each word you will
- Upcase the entire word.
- Reverse the word using a simple
for
loop. (PAPER becomes REPAP) - Write each reversed word to the output file on its own line.
- Report to the user the total number of words.
Version A sample file content (abbreviated):
A Frosted Glass Plate Rested Amidst The Bottles, Glasses, Cups And Saucers Upon The Table. For So Many Dishes, They Held Practically No Food, Save One Plate. The Plate Was Made Of Ordinary Green Glass And Was Likely Kept In The Refrigerated Unit Of The Garde Manger Station Beyond The Swaying Hinged Door, Well Within The Realm Of The Kitchen. The Contents Of The Plate: A Variety Of Leafy Greens, Sliced Radish, Carrot, Celery, Pepperoncini And Pickled Beet. This Plate And Its Colorful Bounty Were Now On Display At The Table For All To See. In Fact, The Only Form Of True Sustenance At This Table Was Upon This Plate. ...
Version B sample file content (abbreviated):
A DETSORF SSALG ETALP DETSER TSDIMA EHT ,SELTTOB ,SESSALG SPUC DNA SRECUAS NOPU EHT .ELBAT ROF OS YNAM ,SEHSID YEHT DLEH YLLACITCARP ...
Submit the project to the Learning Management System as Project5_lastname.java.