Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Part A: Divide by zero exception handling 2) Part B: Input/Number format exception handling 3) Part C: Null pointer exception handling Part A: Divide

image text in transcribed
1) Part A: Divide by zero exception handling 2) Part B: Input/Number format exception handling 3) Part C: Null pointer exception handling Part A: Divide by Zero Exception Handling Objective: To implement at try-catch exception handler. In this part of the lab we are going to implement a new sound method that reduces a sound by a factor passed in as a parameter. This is accomplished by dividing each sample value by that parameter value. So, add a new method to Sound.java called soundDivision (.., that returns nothing, and takes one integer parameter, called divisor. 1) 2) Here is pseudocode for this method, which is very simple: REPEAT for each sample in the sound REMEMBER - get the sample from the sound CALCULATE divide the sample by the parameter divisor REMEMBER save the new, divided sample back into the sound When you think you have a working method, create a new Lab7TestProject. To test your method, type the following commands into the main method of your Lab7TestProject file: 1) // set up path to where sound files are String path"i replace with your path // specify filename of sound to test with string filename = "preamble.way"; // open the sound Sound soundl new Sound (path filename) soundl.explore) soundl.soundDivision (8) soundl.explore) 3) Run Lab7TestProject to test the sound. It should sound quieter. Now, change your program so that instead of sending in 8 as the divisor parameter, you send a 0. Write down what happens: 1) Part A: Divide by zero exception handling 2) Part B: Input/Number format exception handling 3) Part C: Null pointer exception handling Part A: Divide by Zero Exception Handling Objective: To implement at try-catch exception handler. In this part of the lab we are going to implement a new sound method that reduces a sound by a factor passed in as a parameter. This is accomplished by dividing each sample value by that parameter value. So, add a new method to Sound.java called soundDivision (.., that returns nothing, and takes one integer parameter, called divisor. 1) 2) Here is pseudocode for this method, which is very simple: REPEAT for each sample in the sound REMEMBER - get the sample from the sound CALCULATE divide the sample by the parameter divisor REMEMBER save the new, divided sample back into the sound When you think you have a working method, create a new Lab7TestProject. To test your method, type the following commands into the main method of your Lab7TestProject file: 1) // set up path to where sound files are String path"i replace with your path // specify filename of sound to test with string filename = "preamble.way"; // open the sound Sound soundl new Sound (path filename) soundl.explore) soundl.soundDivision (8) soundl.explore) 3) Run Lab7TestProject to test the sound. It should sound quieter. Now, change your program so that instead of sending in 8 as the divisor parameter, you send a 0. Write down what happens

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions