Question: Using Java write a complete class for the following Assignment and name it Hex You should provide constructors, at least provide following methods: getHex(); setHex(
Using Java write a complete class for the following Assignment and name it Hex
You should provide constructors, at least provide following methods:
getHex(); setHex( String h); addHex(String h); subHex(String h); showResult(); coverToBase10(String h); or any methods you think is good to offer.
add should work like:
Hex result = h1.add(h2); where h1, h2 are Object of class Hex.
Hex subResult = h1.sub(h2);
Assignment is as follows:
Hexadecimal numerals are integers written in base 16. The 16 digits used are 0 through 9 plus a for digit 10, b for the digit 11, c for the digit 12,d for the digit 13, e for the digit 14, and f for the digit 15. For example, the hexadecimal numeral is same as base 10 numeral 0-9 and the hexadecimal 1d is same the base 10 numeral 29. Write a program to perform addition of two hexadecimal numerals each up to 10 digits. If the result of the addition is more than 10 digits long, then simply give the output message Addition Overflow and not the result of addition. Use arrays to store hexadecimal numerals as arrays of characters. Include a loop to repeat this calculation for new numbers until the user she or he wants to end the program.
Don't forget to use the Java language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
