Write a program that reads the contents of the adjacent file: BinaryNumbers.txt and converts each number,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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% 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%
Expert Answer:
Answer rating: 100% (QA)
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... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
How many formula units are in a 35.6 g sample of an imaginary compound XM3? Atomic mass of X = 29 g/mol Atomic mass of M = 34.5 g/mol Make sure to show all work, use significant figures, and end with...
-
The ledger of Blossom Corporation has the following account balances at the company's first year end of October 31, 2022. Accounts payable $3,090 Interest payable 210 Accounts receivable 4,410...
-
What is the correct TDS ratio (percentages are rounded up)? Gross Income $48,000 Chequing Account Balance $1,000 Net Income $38,000 Property Taxes $4,800 Heating Payments $3,600 Annual Car Payment...
-
Find any horizontal or vertical asymptotes. f(x) = = X 1- X
-
Turner Distribution markets CDs of numerous performing artists. At the beginning of March, Turner had in beginning inventory 2,500 CDs with a unit cost of $7. During March, Turner made the following...
-
An atom in a molecule has one single bond and one triple bond to other atoms. What hybrid orbitals do you expect for this atom? Describe how you arrive at your answer.
-
In your chemistry classes, you have probably learned that, in a chemical reaction, the mass of the products is equal to the mass of the reactants. That is, the mass of the substances produced in a...
-
The income statement for Sutherland, Inc., appears below. SUTHERLAND, INC. Income Statement For the Year Ended December 31, 2014 Net sales ..........................$400,000 Cost of goods sold...
-
Suppose that, on a 3,000-mile New York to Los Angeles flight, United, American, and Southwest flew a total of 280 empty seats, costing them a total of $143,160. If United had three times as many...
-
Grimes Corporation began business in 2017 and incurred losses for its first two years. In 2019, it became profitable. The following table shows Grimess taxable income before consideration of its...
-
Discuss the factors involved in writing a clear and concise Problem Statement and Purpose Statement. Then share your proposed SLP 1 sections for the Problem Statement and Purpose Statement for peer...
-
The process varies depending on the group being surveyed, such as family members, communities, or select groups involved in specific markets like insurance or healthcare. They also use existing...
-
The Bank of England's Monetary Policy Committee raised its interest rates fourteen times since December 2021. As in the US, firms in England often borrow funds or take funds out of alternative uses...
-
Design a one-way slab for the inside of a building using the span, loads, and other data given in the figure below. 11'-8" GIVEN SDL 10 psf (super imposed dead load not including the slab selfweight)...
-
Check out PISA and your textbook for data relating to the expenditures on education per country. There are different sectors of education that receive funding. Why are there differences in the amount...
-
1. Explain the Law of Diminishing Returns. To do that: a) Consider all pertinent variables to include in your analysis. b) Provide data and graphs to support your answer(s). 2. Discuss the nature of...
-
Closed Tech Ltd. issued convertible bonds on 1 July 20X8. The 15-year, 4% $12,750,000 bonds pay interest semi-annually each 30 June and 31 December. At the investor's option, each $1,000 bond is...
-
If the jobs displayed in Table 18.24 are processed using the earliestdue-date rule, what would be the lateness of job C? TABLE 18.24 Processing Times and Due Dates for Five Jobs Job C D E...
-
Write a complete C# app to prompt the user for the double radius of a sphere, and call method SphereVolume to calculate and display the volume of the sphere. Write an expression-bodied method...
-
State whether each of the following is true or false. If false, explain why. a) When strings are compared with ==, the result is true if the strings contain the same values. b) A string can be...
-
Fill in the blanks in each of the following statements: a) Use the _________property of the List class to find the number of elements in the List. b) The LINQ _________clause is used for filtering....
-
Figure 7.18 shows a liquid-level system in which two tanks have cross-sectional areas \(A_{1}\) and \(A_{2}\), respectively. The volume flow rate into tank 1 is \(q_{\mathrm{i}}\). A pump is...
-
For the three-room house shown in Figure 7.35, all rooms are perfect squares and have the same dimensions. An air conditioner produces an equal amount of heat flow \(q_{\mathrm{ho}}\) out of each...
-
Consider the single-tank liquid-level system shown in Figure 7.19, where the volume flow rate into the tank through a pipe is \(q_{\mathrm{i}}\). The liquid leaves the tank through an orifice of area...
Study smarter with the SolutionInn App