Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to convert a number from decimal notation to a number expressed in a number system whose base ( or radix ) is

Write a program to convert a number from decimal notation to a number expressed in a number
system whose base (or radix) is a number between 2 and 16. The conversion is performed by
repetitious division by the base to which a number is being converted and then taking the
remainders of division in the reverse order using a stack. For example, in converting to binary,
number 6 requires three such divisions: 62=3 remainder 0,32=1 remainder 1, and finally, 12=
0 remainder 1. The remainders 0,1, and 1 are put in the reverse order so that the binary equivalent
of 6 is equal to 110.
Number systems with bases greater than 10 require more symbols. Therefore, use capital letters.
For example, a hexadecimal system requires 16 digits: 0,1,dots,9,A,B,C,D,E,F. In this system,
decimal number 26 is equal to 1A in hexadecimal notation, because 2616=1 remainder 10(that is,
A), and 116=0 remainder 1. Java code and again using stack as mentioned.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

Students also viewed these Databases questions

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago