Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

hexadecimal convert to decimal

anyone can help with convertion of hexadecimal to decimal nad vice versa?
urgent ..plz help me out.....the problem is as followed:

We perform hexadecimal addition as follows:

10A
+FC
---
206(518 decimal)

Your task is to create a limited 'HexadecimalCounter'class. This particular class has just ONE private data member:

decimalValue

This attribute could be an int or longint, you choose. It stores the decimal (integer) value of a hexadecimal number. It is easier to work with a value stored in decimal terms and to output results in hexadecimal, as you will soon discover!

The hexadecimal number 10A would be stored as 266 (decimal) in decimalValue. You need to provide for your HexadecimalCounter class:

a default constructor that creates a zeroed hexadecimal counter object. As an example the following code:

HexadecimalCounter myNewValue;

will result in an instance of myNewValue being created with decimalValue initialised to zero.

an overloaded constructor that sets decimalValue to the equivalent value of an integer that is passed in. As an example the following code:

HexadecimalCounter myNewValue(121);

will result in an instance of myNewValue being created with decimalValue initialised to +121 decimal.

an overloaded constructor that sets decimalValue to the equivalent value of an acceptable 'hexadecimal string'; that is passed in. As an example the following code:

HexadecimalCounter myNewValue("10A");

will result in an instance of myNewValue being created with decimalValue initialised to +266 decimal. In the event that the input string is unacceptable, decimalValue will be initialised to zero.


Comments

  • Justin BibJustin Bib USAMember Posts: 0

    ____ < http://forcoder.org /> free video tutorials and ebooks about [ Visual Basic .NET, C#, Java, Assembly, Swift, Objective-C, Go, C++, Visual Basic, Ruby, JavaScript, PL/SQL, Delphi, R, MATLAB, Perl, Scratch, Python, PHP, C Lua, Alice, Dart, Clojure, Rust, Lisp, VBScript, FoxPro, Prolog, ABAP, SAS, Transact-SQL, ML, Fortran, Scheme, Kotlin, Julia, Awk, LabVIEW, COBOL, Hack, Scala, Crystal, F#, Erlang, Bash, D, Logo, Ada, Apex ] __

Sign In or Register to comment.