Question
BASE CONVERTER CODING PROJECT 1. Using the algorithm given below, write a C# program that takes any number in any base (between 2 and 16)
BASE CONVERTER CODING PROJECT
1. Using the algorithm given below, write a C# program that takes any number in any base (between 2 and 16) and converts it to base 10.
Value = 0;
Repeat
Value = (value * N) + [next digit];
Until (no digit remains)
Example: Convert 2F3A (base 16) to decimal
Initialization: value = 0
First pass: value = (value * 16) + 2 = 2
Second pass: value = (2 * 16) + F = 47
Third pass: value = (47 * 16) + 3 = 755
Fourth pass: value = (755 * 16) + A = 12090
Answer = value = 12090 (base 10)
2. Using the algorithm given below, write a C program that converts base 10 numbers to any given base (between 2 & 16).
value = [value to be converted];
repeat
next digit of result = value % N;
value = value / N;
until (value = 0);
Example: Convert 12090 base 10 from decimal to hexadecimal. Program returns modulus
1st pass: next digit = [12090] % 16 = 10 {A}
Value = [12090] / 16 = 755
2nd pass: next digit = [755] % 16 = 3
Value = [755] / 16 = 47
3rd pass: next digit = [47] % 16 = 15 {F}
Value = 47 / 16 = 2
4th pass: next digit = [2] % 16 = 2
Value = [2] / 16 = 0 {breaks}
Answer = 2F3A (base 16)
3. Program needs to be user friendly and should ask user for input and then displays the result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started