Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that reads the contents of the adjacent file: BinaryNumbers.txt and converts each number, one per line, to their decimal equivalent. In
Write a program that reads the contents of the adjacent file: BinaryNumbers.txt and converts each number, one per line, to their decimal equivalent. In addition: a. Write the bin2Dec (String binaryString) method to convert a binary string into a decimal number. b. Implement the bin2Dec method to throw a NumberFormat Exception if the string is not a binary number. c. If the method throws an exception, display "Not a binary number", followed by the input string, as shown below. Sample Program Output: Binary Number Decimal Equivalent 11011 27 00001 1 1000010011 531 011110 30 1101001101 845 10011 19 00101100 44 110110001 433 1011011 91 11011200 Not a binary number: 11011200 0010101 21 101011 43 0100111 39 00000000 100010100 276 011010 26 0010111 23 110001 49 0011100 28 Please note: 1. You may only use material covered in this course so far 2. Programs with syntax errors will not be accepted Output from exception handler Grading Criteria: 1. Program/ Module Description: 10% 2. Following Course Coding Conventions: 10% 3. Correct implementation of try-catch blocks, per above instructions: 40% 4. Output formatting matches examples: 20% 5. Accuracy of results: 20%
Step by Step Solution
★★★★★
3.43 Rating (159 Votes )
There are 3 Steps involved in it
Step: 1
Solution Heres an example implementation of the program that reads the contents of the BinaryNumberstxt file and converts each binary number to its decimal equivalent It also includes the required bin...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started