Write a program that prompts the user to enter a file name and displays the occurrences of each letter in the file. Letters are case-insensitive. Here is a sample run:
Enter a filename: Lincoln.txt
Number of A’s: 23
Number of B’s: 0
Number of C’s: 12
……
Number of Y’s: 5
Number of Z’s: 7
x=input("Enter File Name:") #TO take input file name from the
user
file=open(x,'r') #opening the requested file with read access
x=file.read() #reading the content of the file
for i in range(ord('A'),ord('Z')+1): #ord reveal the ASCII values
of the chahracter
print("NUMBER of "+chr(i)+"'s:
",x.count(chr(i))+x.count(chr(i+32))) #chr() used to convert ASCII
to characters
#We counted considering string as case insensitive
OUTPUT:
NOTE: Program was written in python as you didn't specify any language. Use the same logic to implement in other languages. If you have any doubts comment below. I'll help you.
Don't forget to rate the answer.
Write a program that prompts the user to enter a file name and displays the occurrences...
PLEASE complete this in java. Write a program that prompts the user to enter a file name and displays the occurrences of each letter in the console window and in a file. Letters are case insensitive. Use “USAconst.txt” for input and “letterCount.txt” for output. Use try- catch blocks to handle checked exceptions. Here is a sample file output: is ወ The ወ ው The Enter file name: USAconst.txt The occurrence of A's is 2675 The occurrence of B's is 612...
Write a case-insensitive pattern searcher that prompts the user for a file name and a pattern, and the program reports on the number of times the pattern occurs within the file. If you were searching for the pattern "ab" occurrences of "ab", "AB", "aB", "Ab" would all contribute to the count. Hint: The argument to the string function count could be a multi-character string. Shown here are three sample runs of the program: >>> main() Enter file name: AllYouNeedIsLove.txt Enter string...
Write a program that prompts the user to enter a binary string and displays the corresponding decimal integer value. For example, binary string ‘10001’ is 17 (1*24 +0*23 +0*22 +0*2 + 1 = 17) A sample run : Enter a binary: 10001 17 Enter second integer: 110 6 Use python.
****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of a file. The program encoded sentences in the file and writes the encoded sentences to the output file. Enter the file name: messages.txt Output: encoded words are written to file: messages.txt.swt The program reads the content of the file and encodes a sentence by switching every alphabetical letter (lower case or upper case) with alphabetical position i, with the letter with alphabetical position 25...
*12.1 (Name for both genders) Write a program that prompts the user to enter one of the filenames described in Exercise 12.31 and displays the names that are used for both genders in the file. Here is a sample run: Enter a file name for baby name ranking: Babynamesranking2001.txt 69 names used for both genders They are Tyler Ryan Christian ... The original question had me enter a URL and file to access all the data, but the website no...
Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...
JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...
write a java program that displays the following: Write a Java program that prompts the user to enter an integer and determines whether 1. it is divisible by 5 and 6, whether on 2. it is divisible by 5 or 6, 3. it is divisible by 5 or 6, but not both. Here is a sample run of this program: Sample run: Enter an integer: 10 Is 10 divisible by 5 and 6? false Is 10 divisible by 5 or...
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
Design a Python program that prompts the user to enter "yes" or "no" and validates the input. (Use a case-insensitive comparison) and another Python program that prompts the user to enter a number in the range of 1 through 100 and validates the input