₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,045 members, 8,420,039 topics. Date: Thursday, 04 June 2026 at 10:03 AM

Toggle theme

Centey's Posts

Nairaland ForumCentey's ProfileCentey's Posts

1 (of 1 pages)

ProgrammingRe: Java Prog That Converts Binary To Decimal by Centey(m): 4:46pm On Jan 23, 2008
[color=#000099][/color]
chukxy:
pally, just like i promised yesterday, here is the solution to the problem:

class BinaryDec
{
public static void main(String arg[])
{
String binaryno = arg[0];
int decno;
decno= Integer.parseInt(binary,2);
System.out.println(''The Decimal equivalent =''+decno);
}
}

compile, javac BinaryDec.com
run java BinaryDec 1101

the ans will be 13.

Thanks and stay connected.
The program is a good one and it actually ran.
However on compilation, it threw some errors
1. The variable declared was binaryno in line 5 but the variable used in line 7 was binary, thus change binary to binaryno in line 7
2. The quotations marks should be double qoute " and not two single quotes '' in line 8

Good program, Kudos

1 (of 1 pages)