Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
 
CS 1301 
Lab 10 
 
Working with Single-Dimensional Arrays - Chapter 7 
 
 
Use JGrasp to design and implement the following programs (from the end of Chapter 7 in the textbook) and 
understand what they do.  
 
Exercise 1: Design and implement a Java program for programming exercise 7.1, page 276 (name it 
AssigningGrades), to computer students grades as described in the problem statement.  Use an array to 
store the entered grades. Follow the instructions in the problem statement (and the sample run given in the 
textbook) to design your program. Design the main method of your program such that it allows the user to re-run 
the program with different sets of inputs (i.e., use a loop). Document your code, and organize and space the 
outputs properly. Use escape characters and formatting objects when applicable. 
 
Exercise 2: Design and implement a Java program for programming exercise 7.8, page 277 (name it 
AverageArray), to compute and display the average of values in an array. Follow the instructions in the 
problem statement. Note that you need to write 2 overloaded methods as specified. Design the main method of 
your program such that it allows the user to re-run the program with different sets of inputs. Document your 
code, and organize and space the outputs properly. Use escape characters and formatting objects when 
applicable. 
 
Exercise 3: Design and implement a Java program for programming exercise 7.27, page 282 (name it 
IdenticalArrays), as specified in the problem statement. Follow the instructions in the problem statement 
and use the given sample runs to test your code. Design the main method of your program such that it allows 
the user to re-run the program with different sets of inputs. Document your code, and organize and space the 
outputs properly. Use escape characters and formatting objects when applicable. 
 
Exercise 4:  Design and implement a Java program (name it ArrayMethods), that defines 4 methods as 
follows: 
 
 int arrayMax (int [ ] arr) determines and returns the maximum value within an array 
 int arrayMin (int [ ] arr) determines and returns the minimum value within an array 
 void arraySquared (int [ ] arr) changes every value within the array to value² 
 void arrayReverse (int [ ] arr) reverses the array (for example: 7 8 1 2 becomes 2 1 8 7) 
 
Test your methods by creating an array of length 5 within your main method and filling it with random numbers 
between 1 and 1000. Your program should then display the original array, display the smallest number in the 
array, display the greatest number in the array, display the revered array, and display the square of each value 
in the array. Your main-method should invoke each method exactly once, with each invocation use the original 
array as the actual parameter. No printing within the methods. Document your code, and organize/space the 
outputs properly. Use escape characters and formatting objects when applicable. 
 
 
Instructions: 
 
1.  Programs must be working correctly. 
2.  Programs must be completed and checked before working assignment #10. 
3.  Programs must be checked by the end of the designated lab session. 
 
 
 
Page 1 of 1