Program to change base system, JAVA Programming

Write a program called BaseConverter that prompts (asks) the user for a base 10 number and another number, between 2 and 10 inclusive. This second number is the base to which to convert the first number. The program outputs the original number and the number converted to the given base. If the base number is less than 2 or greater than 10, the program outputs a message and terminates.

Note: this problem is to be solved using only the Scanner, String and System classes. Arrays or other data structures are not allowed.

System.exit( ) is not be used anywhere in any of the Tasks, marks will be deducted if it is used anywhere in this assignment.

The algorithm for this conversion is to keep dividing the base 10 number by the conversion base, recording the remainders, until the base 10 number is 0. Then write the result, starting from the bottom and work up to the top.

> java BaseConverter
Enter decimal number >> 153
Enter base to convert to >> 8
153 in base 10 converted to base 8 is 231
 
java BaseConverter
Enter decimal number >> 153
Enter base to convert to >> 7
153 in base 10 converted to base 7 is 306
 
> java BaseConverter
Enter decimal number >> 153
Enter base to convert to >> 5
153 in base 10 converted to base 5 is 1103
 
> java BaseConverter
Enter decimal number >> 153
Enter base to convert to >> 2
153 in base 10 converted to base 2 is 10011001
 
> java BaseConverter
Enter decimal number >> 153
Enter base to convert to >> 10
153 in base 10 converted to base 10 is 153

> java BaseConverter
Enter decimal number >> 153
Enter base to convert to >> 16
Conversion base must between 2 and 10 inclusive

Posted Date: 2/16/2013 5:36:55 AM | Location : United States







Related Discussions:- Program to change base system, Assignment Help, Ask Question on Program to change base system, Get Answer, Expert's Help, Program to change base system Discussions

Write discussion on Program to change base system
Your posts are moderated
Related Questions
Explain what is Naming Applets in java applets? You can give an applet a name by using the NAME attribute of the APPLET element. This allows communication between different app

Project Description: I want to build a camera application for android. By default android will add metadata for the image, for e.g.  Date, time, resolution, gps tag etc..In this

What is Methods in java explain with an example? Data types aren't much use unless you can do things along with them. For this reasons classes have techniques. Fields say what


Modify the client server application developed for phase 1 IP2 to be a Multithreaded Server (i.e. the server can handle concurrent requests from more than one client). Submit your

Prompt the user for an int between an upper and lower boundary. Reuse the validateInput() method from project 2 to validate if the input is in bounds. If it is not, print an error


Payroll Calculator for Both Hourly and Commission Employees In assignment 13, we will create a payroll calculator that calculates   gross pay ,   taxes , and   net pay   fo

I do not understand how to do this? can someone help me?

Write a program called Drivers that displays information about Formula 1 drivers and their teams.     The program starts by prompting (asking) the user for the name of an input tex