NumberFormatException
. Write the
bin2Dec(String binaryString)
method to convert a binary string
into a decimal number. Implement the bin2Dec
method to throw a
NumberFormatException
if the string is not a binary string.
In main, allow a user to enter a binary string and test your method.
ch12pr7.java
.java ch12pr7
) user provides input:
Enter a binary number: 1001
Decimal value is 9
java ch12pr7
) user provides input:
Enter a binary number: 1001a1001
Error. Input was not a binary number.
ch12pr11.java
.java ch12pr11
) user provides input,
example file:
Enter an input filename: withJLD.txt
Enter a string to remove: JLD
Enter an output filename: withoutJLD.txt
Resulting file:
Hello class!
java ch12pr11
) user provides input:
Enter an input filename: nothing
Enter a string to remove: JLD
Enter an output filename: withoutJLD.txt
Error. Cannot find input filename.
ch12pr19.java
.java ch12pr19
):
There are 277 words in the Gettysburg Address.
ch12pr21.java
.java ch12pr21
) user provides input,
example file:
Please enter a filename: Scrabble.txt
File 'Scrabble.txt' lists words out of order.
The first two out of order words are 'ZA' and 'AAH'.
java ch12pr21
) user provides input,
example file:
Please enter a filename: LongScrabble.txt
File 'LongScrabble.txt' lists words in order.
Summary.txt
that contains the total salary
for assistant professors, associate professors, full professors, and all
faculty, respectively, and contains the average salary for assistant
professors, associate professors, full professors, and all faculty,
respectively.
ch12pr25.java
.java ch12pr25
) note the program itself
does not display any output:
total average
assistant 20246511.91 65949.55
associate 28844146.58 83849.26
full 35678051.41 102229.37
all 84768709.90 84768.71