Note 1 the input data may include non-digit characters such


Input Data:

  • Enter a phone number (set up a string-type object for the phone number)
  • inputting is done at the keyboard.
  • examples:
  • (703) 323-3000
  • 011-44-20-7797-782
  • NOTE 1: The input data may include non-digit characters, such as parentheses, dashes, etc.
  • NOTE 2: Your program should handle phone numbers of any length.
  • NOTE 3: Your program should skip non-digit characters and process only characters '0' through '9'.

Output Data:

  • Display the phone number, using a format like the following:
  • Example 1:
  • The phone number you entered is 703-323-3000.
  • Display the content of the array that holds the count for each digit in the string. Use a format similar to the following:
Digit 0 showed up 4 times.
Digit 1 showed up 0 times.
Digit 2 showed up 1 times.
Digit 3 showed up 4 times.
Digit 4 showed up 0 times.
Digit 5 showed up 0 times.
Digit 6 showed up 0 times.
Digit 7 showed up 1 times.
Digit 8 showed up 0 times.
Digit 9 showed up 0 times.
  • Example 2:The phone number you entered is 011-44-20-7797-782.
  • Display the content of the array that holds the count for each digit in the string. Use a format similar to the following:
Digit 0 showed up 2 times.
Digit 1 showed up 2 times.
Digit 2 showed up 2 times.
Digit 3 showed up 0 times.
Digit 4 showed up 2 times.
Digit 5 showed up 0 times.
Digit 6 showed up 0 times.
Digit 7 showed up 4 times.
Digit 8 showed up 1 times.
Digit 9 showed up 1 times.

Processing:

  • Here's an algorithm to get this done:
set up an integer array of size 10 
initialize each element to zero 
input string of phone number 
set SIZE = length of the string 
set up a loop to iterate SIZE times 
 get next character 
 if character is numeric then update array appropriately 
 (for example: if the character is '7' then increment array[7] by 1. 
 } 
  • Display BOTH of the following using appropriate messages (see above examples):   the original phone number

Solution Preview :

Prepared by a verified Expert
Business Management: Note 1 the input data may include non-digit characters such
Reference No:- TGS02556696

Now Priced at $10 (50% Discount)

Recommended (94%)

Rated (4.6/5)