Write the bin2decstring binarystringmethod to convert a


Write the bin2Dec(String binaryString)method to convert a binarystring into a decimal number (yourmethod should return aninteger ). Implement the bin2Decmethod to throw a NumberFormatException if thestring is not a binarystring .

Test yourmethod in aprogram that prompts the user to input a binarystring and uses your bin2Decmethod to print out the decimal equivalent of thatstring . If themethod throws an error, have yourprogram catch it and print "Not a binarystring ." before terminating.

SAMPLE RUN #1: java NumberFormat Interactive Session Standard Input Standard Error (empty) Standard Output Hide InvisiblesHighlight: NoneStandard Input OnlyPrompts OnlyStandard Output w/o PromptsFull Standard OutputAllShow Highlighted Only

Enter·a·binary·string:1011000101

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write the bin2decstring binarystringmethod to convert a
Reference No:- TGS02386226

Now Priced at $10 (50% Discount)

Recommended (94%)

Rated (4.6/5)