Instructions Task: Exception handling This program will be reused in the next lab. Save it at a safe place. Write the bin2Dec(String binaryString) method to convert a String representing a binary number into a decimal number (assume it fits into an int type). Implement the bin2Dec method to throw a NumberFortmatException if the string is not a binary string. Write a test main method, in the same class, that prompts the user to enter a binary number as a String and displays its decimal equivalent. If the bin2Dec method throws an exception, display "Not a binary number:" followed by a space and the input string. This message (for example, "Not a binary number: 123" in the sample runs) should be put as the message field in the exception object, which will be returned by the getMessage() method. Below are sample runs. Enter a binary number: 101 The decimal value for binary number 101 is 5 Enter a binary number: 110110110 The decimal value for binary number 110110110 is 438 Enter a binary number: 123 Not a binary number: 123
Instructions Task: Exception handling This program will be reused in the next lab. Save it at a safe place. Write the bin2Dec(String binaryString) method to convert a String representing a binary number into a decimal number (assume it fits into an int type). Implement the bin2Dec method to throw a NumberFortmatException if the string is not a binary string. Write a test main method, in the same class, that prompts the user to enter a binary number as a String and displays its decimal equivalent. If the bin2Dec method throws an exception, display "Not a binary number:" followed by a space and the input string. This message (for example, "Not a binary number: 123" in the sample runs) should be put as the message field in the exception object, which will be returned by the getMessage() method. Below are sample runs. Enter a binary number: 101 The decimal value for binary number 101 is 5 Enter a binary number: 110110110 The decimal value for binary number 110110110 is 438 Enter a binary number: 123 Not a binary number: 123
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Write the code in java and understand what the question says and give me the code and don't copy or plagiarize please

Transcribed Image Text:Instructions
Task: Exception handling
This program will be reused in the next lab. Save it at a
safe place.
Write the bin2Dec(String binaryString) method to
convert a String representing a binary number into a
decimal number (assume it fits into an int type).
Implement the bin2Dec method to throw a
NumberFortmatException if the string is not a binary
string.
Write a test main method, in the same class, that
prompts the user to enter a binary number as a String
and displays its decimal equivalent. If the bin2Dec
method throws an exception, display "Not a binary
number:" followed by a space and the input string. This
message (for example, "Not a binary number: 123" in
the sample runs) should be put as the message field in
the exception object, which will be returned by the
getMessage() method. Below are sample runs.
Enter a binary number: 101
The decimal value for binary number 101 is 5
Enter a binary number: 110110110
The decimal value for binary number 110110110 is 438
Enter a binary number: 123
Not a binary number: 123
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education