---+Counting Letters with methods: Fall 2025 ---++ Learning Objective(s) * Learn to use methods * Abstraction ---++ Overview of the Program Modify the previous program so that it uses methods ---++ Specifics * The program is to be called <b>CountLettersMethods</b>. * The program should prompt for the name of the file to be processed. * Exceptions must be caught and properly handled. * If a letter does not occur on a line (or in the file), it should not be displayed. * You may assume the file only contains lowercase letters. * You should have a method called <b>countString</b> that is sent a character and a line (as a string). It returns the number of times that character appears in that string. * You should have another method called <b>countFile</b> that is sent a character and an open file. It outputs how many times that character occurs on each line in the file. Because it does not open the file, it should not close the file. * You may use the posted solution from the previous lab. ---++ Sample dialogue Below is a sample dialogue. The prompts may vary but the input given by the user is to be the same format. Your output can vary somewhat as long as the required data is nicely displayed in the order specified. <pre> What file would you liked to have processed? <b><font color="blue">small.txt</font></b> Line 1 has 1 a's. Line 2 has 1 a's. Line 4 has 1 a's. Line 4 has 1 d's. Line 2 has 1 e's. Line 4 has 1 e's. Line 2 has 1 f's. Line 4 has 1 f's. Line 1 has 1 h's. Line 3 has 1 h's. Line 1 has 2 i's. Line 2 has 1 i's. Line 3 has 1 i's. Line 3 has 1 j's. Line 2 has 3 l's. Line 2 has 1 m's. Line 4 has 1 o's. Line 4 has 1 r's. Line 1 has 2 s's. Line 2 has 1 s's. Line 3 has 1 s's. Line 4 has 1 s's. Line 1 has 1 t's. Line 3 has 2 t's. Line 3 has 1 u's. Line 3 has 1 w's. Line 4 has 2 w's. </pre> You can also run a solution for this program if you want. See classroom instructions for more details. ---++Lab Hints * Hint 1: See class examples for working with files. Make sure your data files are in the same folder as your code are that is your current folder * Hint 2: [[CSC121F2025Lab05Hint02][Recommended steps for developing]] * Hint 3: [[CSC121F2025Lab05Hint03][Getting ready to process the next letter]] ---++ Submission * Create a software development report * For the system design, you need to make your own flowchart. * For testing report, * make sure your tests ensure that each statement is executed at least one. * your <b>expected output</b> <font color="red">CANNOT</font> be pasted from the dialogue of a running. Only the actual output may be pasted * It should contain at least one different input that is an "error" * For the improvement section, specify how many points were lost from the last lab that you should not lose points for on this lab because you corrected the problem * create a pdf document from your software development report * create an empty zip folder * place *only* !CountLettersMethods.java, your own testing files (not mine) and your pdf document into it * submit the zip folder on canvas ---++ Optional improvements Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor. 1. Treat uppercase letters as lowercase letters 1. For each letter in the file, print the first line and last line that contain that letter (after printing how many letters in each line). 1. Submission instructions a. Call this program <b>CountLettersMethods2</b> add it to the zip folder that contains the original solution.
This topic: CenterForComputing
>
WebHome
>
Syllabi
>
CSC121SylF2025
>
CSC121F2025Lab06
Topic revision: r1 - 2025-08-02 - CathyBareiss
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback