[SOLVED] Programming Project #5- Processing strings

30.00 $

Category: Tags: , , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon P05-brzicm.zip (162.5 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Project #5: Processing strings
In this project, you must solve one of two tasks, depending on how your program is executed.

For the first task, you will be given a phoneword (a phone number that spells a word by using the letters on your telephone keypad – see the picture below), and you must print its respective phone number. For instance, the phoneword 1-800-FLOWERS refers to the phone number 1-800-3569377.

For the second task, you will be given a letter and a phrase, and you must print the percentage of words in this phrase that contains this letter. For instance, the letter ‘a’ appears in 33.3% of the words in the sentence “you will pass”.

Execution specification:

For this project, your program will be run with command-line arguments. For the first task, a program named “a.out” will be executed as follows:

./a.out phone

where the first argument “phone” indicates that the current test case is a valid input for the first task. For the second task, a program named “a.out” will be executed as follows:

./a.out phrase [a-z]

where the first argument “phrase” indicates that the current test case is a valid input for the second task, and the second argument is the letter for which you must count the words.

Input specification:

For the first task, the input contains a single line with the phone word, which has at most 15 characters. It only contains digits (‘0’ to ‘9’), hyphens (‘-‘) and uppercase letters (‘A’ to ‘Z’).

For the second task, the input contains a single line with a phrase. A phrase is a sequence of words separated by a single space. There will be no consecutive spaces. The minimum number of characters in a sentence is 1 and the maximum is 1000. All words are composed of lowercase letters only.

Output specification:

For the first task, your program must print a single line with the phone number for the given phoneword. Digits and hyphens in the input are also part of the output. Do not forget the new-line character in the end.

For the second task, your program must print a single line with a number representing the percentage of words in the input phrase that contains the letter provided as a command-line argument. This value must have a single digit after the decimal point. Do not forget the new-line character in the end.

Task description:

Example #1:

Command

 ./a.out phone
 APP-OQI-LNX-THF

Example #2:

Command

 ./a.out phone
 1234-5678

Example #3:

Command

 ./a.out phone
 JF-CD-SHQ

Example #4:

Command

 ./a.out phrase a
 you will pass

Example #5:

Command

 ./a.out phrase k
277-674-569-843

1234-5678

53-23-747

33.3

Input

Output

Input

Output

Input

Output

Input

Output

Input

Output

tusafydaxofazi aoybeme ibiranupu
jufynosomop yyaoxikisajyuacug iluqu
lajubadykyyem aoipot oeytu imua
otabybaqyly vijofem anoaaco yfyzyt
epayoiut eotegic aemopyz agouyaye
emyxueuoovauewun ysyoaqihitycoviwe
oyzib edetejaiovud geeykak

13.0

Example #6:

Command

 ./a.out phrase e
 you will pass

0.0

Input

Output

  • P05-brzicm.zip