program that reads an unsigned number in some base and outputs the equivalent value in a target base. The input file providing these values will be organized to allow for comment lines and blank lines along with data lines. Use only a single source file so I can more easily script the downloading and compiling of your submissions.
Develop a C++ program that reads an unsigned number in some base and outputs the
equivalent value in a target base. The input file providing these values will be organized to
allow for comment lines and blank lines along with data lines. Use only a single source file so I
can more easily script the downloading and compiling of your submissions.
Your program must require a single command line argument, the name of an input file. This
input file will consist of any number of lines, each falling into one of three varieties:
1. Comment - These lines always start with an at-symbol ('@') and should be completely
ignored.
2. Blank line - Used to visually organize the input file and should be completely ignored.
3. Data line - These are the ones your program will process and are described below.
Data lines will all have exactly 3 items separated by a single space character and end with a
newline:
1. an input base (2 through 36) identified in decimal. Digits representing coefficients
between 10 and 35 will use the letters 'A'-'Z' and/or 'a'-'z' (i.e., they could be upper or
lower case)
2. an input value in that base whose binary equivalent will never be more than 30 bits
long
3. an output base (2 through 36) identified in decimal
For each Data line from the input file, you must output:
1. the line number of the input file this data line is on (starting the file with line 1… same as
a text editor would show)
2. a colon followed by a space
3. the equivalent of the input value in the output base using upper case letters A-Z for
any coefficients with the value of 10-35. NEVER print any leading zeros
a. eg, instead of 000123, you would print 123
b. only exception is if the value itself is zero, as in the example below
Example input file Expected output to console
Input:
@ a first example
8 70 4
2 011100 16
7 0 21
11 3A 10
Output:
2: 320
4: 1C
5: 0
6: 43
Step by step
Solved in 2 steps with 2 images