hey there;
i wanted to write a program to convert binary to decimal.
i did that using the " character approach".
it works just fine.
then i decided to enhance the program by adding an error message whenever the input are invalid (i.e anything other than 0, 1 ), but i havent been able to figure it out yet.
i've been playing around with it but it is still not coming.
I must be missing something because there seems to be no attempt in the posted code to deal with invalid input. We therefore can't tell what you are doing wrong.
WaltP
Posting Sage w/ dash of thyme
10,492 posts since May 2006
Reputation Points: 3,348
Solved Threads: 943
Dave's short version: read all user input as the text it is; interpret it at your leisure.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
> but sitll, it doesn't account for invalid numbers which start with 0 or 1 ( ie 123)!
Maybe put the 'if' statement inside the 'while' loop ?
But separating input from conversion is good as well, as Dave has remarked.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
So post your latest effort, not a description of what you may have tried.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953