Modify to use a for loop.

What will be an ideal response?


```
public void increaseVolumeFor ( )
{
SoundSample [ ] sampleArray = this . getSamples ( ) ;
SoundSample sample = null ;
int value = 0 ;
int index = 0 ;
// loop through all the samples in the array
for ( int i = 0 ; i < sampleArray.length ; i++)
{
sample = sampleArray [ i ] ;
value = sample . getValue ( ) ;
sample . setValue ( value *2 ) ;
}
]
```
If you are using Java 1.5 or above modify it to use a for-each loop.
```
public void increaseVolumeForEach ( )
{
SoundSample [ ] sampleArray = this . getSamples ( ) ;
int value = 0 ;
// loop through a ll the samples in the array
for ( SoundSample sample : sampleArray )
{
value = sample . getValue ( ) ;
sample . setValue ( value * 2 ) ;
}
}
```

Computer Science & Information Technology

You might also like to view...

Which type of computer monitor utilizes two sheets of polarizing material to encompass a liquid crystal solution?

A. LED panel B. CRT monitor C. CRT panel D. LCD panel

Computer Science & Information Technology

List method _________ returns the number of times a specified element occurs in a list.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Which tag is used to delineate cells in the body of a table?

(a) (b) (c) (d)

Computer Science & Information Technology

When creating a chart from data in a worksheet, the data series is surrounded by a(n) ________border

Fill in the blank(s) with correct word

Computer Science & Information Technology