![]() |
CS1101: Laboratory 12(a)Converting from Decimal to BinaryAcademic Year 2006-2007Lecturer: Dr. Barry O'SullivanDepartment of Computer Science University College Cork |
The objective of this lab is to ensure that students can implement decimal to binary conversion in Java using the successive halving method.
Write a program called Converter.java
that takes a positive decimal integer as input
and prints out its representation in binary
represented as a string.
You should use successive halving to perform the conversion.
The successive halving method consists of dividing the given number by 2 until the number 0 has been reached. The remainders are used to construct the equivalent binary number. See Figure 1: for an example.
Figure 1: An example of converting from decimal
to binary using halving.
To submit your assignment please put your program in a Java file called
Converter.java
.
To submit it, type the following from the command prompt from one of the
lab machines:
cs1101submit Converter.javaThe submission deadline is 5pm on Friday 23rd of March.
Return to the CS1101 Home Page