This is not a writing assignment so it should not be rejected for being as such. Write a main method and a complete static method named printRepeat that work together as described here. Include pseudo code to show how you planned to do the work. main should prompt the user using a Scanner170 object to ask for a single letter between a and z (lower case) from the keyboard input; if the user enters anything else reprompt until they enter a proper input. Main also creates a second Scanner170 object to read from a file called repeat.txt (provided with the exam). Finally, main calls the printRepeat method with the second Scanner170 and the input letter and prints out the value returned from printRepeat. printRepeat takes as parameters a Scanner170 object and a one letter long String; it returns a int. The method reads lines of text from the Scanner170 object it received as a parameter. Each line read consists of a number and a string (separated by at least one blank). The method should work with any number of lines in the Scanner170 object (including zero). For each line read, the method prints out to the user “>>: “ followed by the string from the file duplicated number of times on a single line. The string read from the file may contain any symbols including special characters and numbers. The method also checks to see if the string from the file contains the letter it was given as second parameter. Keep count of how many lines in the file have letter included in their string. When the entire file has been processed, return that count to the calling program. Be sure main and all methods include clear pseudo code to show your plan. See example output below (the results depend on what letter the user enters for matching): *** Use proper programming style and test your code until you believe it works correctly *** Example run produces something like this:
This is not a writing assignment so it should not be rejected for being as such.
Write a main method and a complete static method named printRepeat that work together as described here. Include pseudo code to show how you planned to do the work.
main should prompt the user using a Scanner170 object to ask for a single letter between a and z (lower case) from the keyboard input; if the user enters anything else reprompt until they enter a proper input. Main also creates a second Scanner170 object to read from a file called repeat.txt (provided with the exam). Finally, main calls the printRepeat method with the second Scanner170 and the input letter and prints out the value returned from printRepeat.
printRepeat takes as parameters a Scanner170 object and a one letter long String; it returns a int. The method reads lines of text from the Scanner170 object it received as a parameter. Each line read consists of a number and a string (separated by at least one blank). The method should work with any number of lines in the Scanner170 object (including zero). For each line read, the method prints out to the user “>>: “ followed by the string from the file duplicated number of times on a single line. The string read from the file may contain any symbols including special characters and numbers. The method also checks to see if the string from the file contains the letter it was given as second parameter. Keep count of how many lines in the file have letter included in their string. When the entire file has been processed, return that count to the calling program.
Be sure main and all methods include clear pseudo code to show your plan.
See example output below (the results depend on what letter the user enters for matching):
*** Use proper programming style and test your code until you believe it works correctly ***
Example run produces something like this:
For the input file:
Step by step
Solved in 4 steps with 3 images