Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Introduction You will implement a C++ program to decode different string of digits from the input file. This assignment focusses on array management and
1. Introduction You will implement a C++ program to decode different string of digits from the input file. This assignment focusses on array management and string handling in C++. You will also practice string manipulation with predefined string utility functions and basic file operations. 2. Input files - The input file will contain a list of encoded id numbers. The input can range anywhere from 0 to 100 entries. Input might contain empty lines and spaces (empty lines and spaces need to be removed to process each entry correctly). - Each entry will be on its own line and have 2 different parts: the coded characters set and id string. - The id string will consist of digits, alphabet characters, and the '+' sign. - Alphabet characters in the id string will always have a number representation for it in the characters set, each separated by a colon. - Semicolon is used to separate characters in the set and id string. - The id string will always come after the characters set in the entry. - Valid entry should have both parts, the characters set and the id string. - Invalid entry should be ignored. - Example of valid entry: a:123;b:456;c:789;id:c11ba3+2b+a *characters set in yellow, id string in green - Example of invalid entry: a:123;b:456;c:789 missing id string id: c11ba3+2b+a missing characters set 3. Decoding process Example input: a:123;b:456;c:789;id:c11ba3+2b+a - Replace all the alphabet characters in the id string with its number representation in the characters set. a:123;b:456;c:789;id:c11ba3+2b+a789114561233+2456+123 - The plus sign (+) should be replaced by the repeated sum of the previous digits (see below for details on the computation). The first plus sign reduces to 5, and the second plus sign reduces to 9 789114561233+2456+12378911456123352456+12378911456123352456+123789114561233524569123789114561233524569123 4. Repeated sum of digits The repeated sum of digits compresses a number of digits to a single value from 0-9. Consider the digits in front of the first plus sign above. These digits are: 789114561233. The sum of those digits is 50 , and the sum of these digits is 5 . Since this number falls in the range from 0-9, this is the repeated-sum of the digits. Continuing with the substitution made, the next set of digits in front of the remaining plus sign are: 78911456123352456. The sum of those digits is 72 , and the sum of these digits is 9 . Since this number falls in the range from 0-9, this is the repeated-sum of the digits. 5. Output files - The output file should contain all the valid id in the order they appeared in the input file (empty lines and spaces should be removed). - Each entry should be on its own line
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