CS 101 - Introduction to Computing, Spring 2010

Lab 11

This lab will have you prompt the user for an amount to change the volume of a sound file. You are to prompt the user for a percent value using the getIntNumber() method of the SimpleInput class. You are to then multiply every sample in the sound file by this percent value. The basic calculation is to first multiply by the value entered by the user, then divide the result by 100. Note that if the user enters in a value between 0 and 99, the volume of the sound file will be decreased. If the user enters a value greater than 100, the volume will be increased. If the user enters 100, the volume will be unchanged.

Note you will want to check out the sample Lect41a.java. This code doubles the volume in a sound file by multipling the value at every sample by 2.

Also, remember range of valid sample values is from -32,768 to +32,767. For this lab, you must also check to see if the sample value falls out of this range after the multiplication is done. If the sample value becomes greater than +32,767, set the value to +32,767. If the sample value becomes less -32,768, set the value to -32,768. You will want to check out the sample Lect41b.java.

Here are some sample sound files that can be used for this lab:

The functions of

from the Sound / SimpleSound class are useful for getting the sample values.

Lab Assignment 11

Due: Thursday 4/8/2010 by 11:59 pm

Create a Java program that will:

  1. Contain a comment indicating

  2. Contain the main() method that will

  3. You are also to submit the Java file electronically via the following steps:

    How assignments should be submitted

    1. Go to the blackboard site for the class
    2. Select "Assignments" on the left bar
    3. Locate the correct assignment to submit; click on "View/Complete Assignment" at the bottom of that assignment
    4. Next to "Attach local file", click "Choose file", choose the file you want to submit; please submit only ONE file, properly named.
      For example for lab2, name it Lab2yournetid.java, for example if your Net ID is sfranz3, the filename would be Lab2sfranz3.java
      Please only submit source code file (the .java file, not the .class). Also, if you have any comment about your program, please write it down in the same file; please do NOT write in the "Comments" field on the submission page (this will go into a different file and will be easily missed).
    5. Hit "Submit"
    6. Go back once again to View/Complete assignment and make sure that your file was submitted; also, this page will show your grade and comments (if any) after assignments are graded.

Here are some example sound files you can use with this assignment.