Due: Monday 5/4/15 at 10:00pm
100 points
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | |
Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | |
Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Input to program:
We will get the input to the program form the command line in the following format.
prompt> progName numberToConvert newBase
For example:linux prompt > ./convert 27 2
27 - base 10
11011 - base 2
linux prompt > ./convert 29 8
29 - base 10
35 - base 8
linux prompt > ./convert 44 16
44 - base 10
2C - base 16
You must name your turned in file: converter_xxxxxx.cpp where xxxxxx is your TXstate id number.
Note: The function atoi(char *), included in the library cstdlib will convert a C-style string to an integer.
To convert an int to a string you can do the following:
#include <sstream>
...
int a = 10;
stringstream ss;
ss << a;
string str = ss.str();
Upload your solution on TRACS
Note: This program must be done using a Linux environment using the G++ compiler. You really need to learn how to use Linux and an editor!
There is a lot of help regarding Linux, the STL, editors, stacks, everything, on the web. Use it.
Last Updated: 4/27/15