codinasion-archive / codinasion-monorepo

Community Monorepo
https://codinasion.org
MIT License
52 stars 167 forks source link

[Program]: Write a Scala program to convert hexadecimal to decimal #1309

Open harshraj8843 opened 2 years ago

harshraj8843 commented 2 years ago

Description

Write a Scala program to convert hexadecimal to decimal

Hexadecimal is a base-16 number system. It uses sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The digits are called hexits. A hexit is the smallest unit of information in a computer. A hexit can be used to represent a single value, such as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, or F, or it can be used to represent a single state, such as on or off.

To convert a hexadecimal number to decimal, we can use the following algorithm:

  1. Multiply the first hexit by 16^0.
  2. Multiply the second hexit by 16^1.
  3. Multiply the third hexit by 16^2.
  4. Multiply the fourth hexit by 16^3.
  5. Repeat steps 3 and 4 until the last hexit.
  6. Add the results of all the multiplications.
  7. The decimal number is the sum of all the multiplications.
Input  : A
Output : 10
How to contribute - Save the solution in `program/program/convert-hexadecimal-to-decimal/convertHexadecimalToDecimal.scala` file
Chirag8023 commented 2 years ago

!assign

harshraj8843 commented 1 year ago

Hey @Chirag8023,

This issue has been assigned to you for more than 15 days.

We are unassigning you from this issue.

If you are still interested in contributing to this issue, please get auto-assigned on the issue by commenting !assign again.

Thanks for your contributions :)