Question
Write a Code in C++/Java (preferably C++) Please READ the instructions carefully in the picture. You will be given an input file ( link is
Write a Code in C++/Java (preferably C++)
Please READ the instructions carefully in the picture.
You will be given an input file (link is here -> https://www.dropbox.com/s/444jofkchu6ylwrames.txt?dl=0 ) this file is a .txt (text) file that contains over 5,000 names that have already been arranged in alphabetical order for you. What you have to do is compute an alphabetical value for each name where A is1, B is 2, C is 3 and so on. Alphabetical value of a name is just the sum of the values of the letters in the name. To compute the name-score for a name, you simply have to mulitply this alphabetical value by its position in the sorted list.
For example: when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. C - 3 O - 15 L - 12 I - 9 N - 14
So, the name-score for COLIN would be 938 * 53 = 49714. What is the sum total of all the name-scores in the file?
Scoring Names You will be using the provided names.txt file, text file containing over five-thousand first names, and you will calculate a score for each name. Begin by reading the names from the file and sorting them in alphabetical order. Then, you will compute an alphabetical value for each name where A is 1, Bis 2, C is 3 and so on. The alphabetical value of a name is just the sum of the values of the letters in the name. To compute the name-score for a name, you simply multiply this alphabetical value by its position in the sorted list. For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 15 12 9 14 53, is the 938th name in the list. So, the name-score for COLIN would be 938 53 49714. What is the sum total of all the name-scores in the file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started