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
1.) Write an application with two user transactions (login which includes viewAllStudents and viewStudent ) with full MVC architecture that displays the details of the selected

Ask1. Storing the Array: Write an application that uses an Array to store 10messages of type String. You will store this Array with 10 messages of your choosing. For example, a mes

Give a example of Using toString() Methods ? Below is a version of CarTest in which uses toString() and System.out.println() instead of printing the fields in a straight line

Write a programme to create a webpage that prints the name of the STUDENT database in Wide Latin font and set the subtitle with description of the STUDENT to the screen. Set the pa


Explain init(), start(), stop(), and destroy() method? The init() method is known as exactly once in an applet's life, while the applet is first loaded. It's generally used to

Task - Defining a Student class The below illustration will explain how to write a class. We want to write a "Student" class which - should be able to store the below charac

In pre-emptive scheduling, the highest priority task implements until it enters the waiting or dead states or a higher priority task comes into existence. In time slicing, a tas

Project Description: A web developer is required to finish a webcam site with basic account management and voting functionality. The website can make use of a third party fla

Describe synchronization in respect to multithreading. With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared res