1. ruchira_sandanayaka Guest

## Java Qs 2....

Question 01
In Mathematics, different number systems are in use. The most commonly used number system is the
decimal number system, which has a base of 10. Other number systems in use are the binary number
system (base 2), octal number system (base 8) and the hexadecimal number system (base 16). They are
all positional number systems, where the decimal value of the number can be obtained by summing the
multiplication of each digit by its corresponding place value. For example, in binary system the
decimal equivalent of the number 1010 can be obtained by the sum: 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 =
1 x 8 + 0 x 4 + 1 x 2 + 0 x 1 = 12
Design a program that would read a number and the base of the number system and print the equivalent
decimal value.
Assume that the base of the number system is always 10 or less. That is, all the digits of the number
system are a subset of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Examples of such number systems are
those with base 2 (binary), base 8 (octal), base 4, base 5 etc.
Your submission should include two documents.
(i) The design of the program in Pseudocode.
(ii) Implementation of the solution in Java
This will consist of a single file that contains a single class called
ITE1101Ass1Mar10XXXXXXXXX and the program should be saved in a file called
ITE1101Ass1Mar10XXXXXXXXX.java
where XXXXXXXXX is your index no
for e.g. the class of the answer submitted by the student with registration number e08420064 would be
ITE1101Ass1Mar10e08420064 and this would be saved in a file called
ITE1101Ass1Mar10e08420064.java
Bonus points: You may earn bonus marks if your program is able to
handle the Hexadecimal number system (base 16) as well.

2. Hello and welcome to the forum. You know of course that all of the folks here are volunteers who enjoy helping others learn Java (especially those who show that they are motivated to learn), and we'll gladly help you with your code or with specific questions on how you can create a certain program. On the other hand, what this forum isn't is a code-producing mill that gives out code on demand. Your "question" is little more than a classic "homework dump" which usually motivates others to post links directing the OP to a tutorial or two or even worse.

So to avoid any of this, let's see a decent try by you towards a solution first. After you've done this and posted it with your specific questions, I'm sure that several of us will be be glad to help you along.

Best of luck!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•