Question: Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file.(i need java code)
Class name: FileLetterCounter
out put should be like this
| Standard Input | Files in the same directory |
|---|---|
QUIT | input.txt letters.txt |
Required Output
Please enter the file name or type QUIT to exit:
Your Program's Output
Please enter the file name or type QUIT to exit:
Test Case 2 - Passed!
| Standard Input | Files in the same directory |
|---|---|
badfilename.txt quit | input.txt letters.txt |
Required Output
Please enter the file name or type QUIT to exit: File: badfilename.txt does not exist. Please enter the file name again or type QUIT to exit:
Your Program's Output
Please enter the file name or type QUIT to exit: File: badfilename.txt does not exist. Please enter the file name again or type QUIT to exit:
Test Case 3 - Failed
| Standard Input | Files in the same directory |
|---|---|
input.txt o | input.txt letters.txt |
Required Output
Please enter the file name or type QUIT to exit: Please enter a character: Letter 'o' occurs 4 times in the file 'input.txt'.
Your Program's Output
Please enter the file name or type QUIT to exit: 1: line 1 2: line 2 3: line 3 4: so on 5: so forth
Test Case 4 - Failed
| Standard Input | Files in the same directory |
|---|---|
letters.txt a | input.txt letters.txt |
Required Output
Please enter the file name or type QUIT to exit: Please enter a character: Letter 'a' occurs 82 times in the file 'letters.txt'.
Your Program's Output
Please enter the file name or type QUIT to exit: 1: A lorem ipsum placeholder text was inadvertently published in The Straits Times, a Singapore newspaper, on 26 April 2014. 2: Today's popular version of Lorem ipsum was first created in the mid-1980s for Aldus Corporation's desktop publishing program 3: PageMaker for the Apple
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
