Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
 
Page 1 of 2 
CS 1301 – Fall 2015 
Lab 8 
 
Working with Methods – Chapter 6 
 
 
Use JGrasp to develop a complete program for each exercise to include a main method and the specified 
method(s) in the problem statement. Notice that the main method is used to test the specified method(s). 
 
Exercise 1: Design and implement a Java program (name it MinMaxAvg) that defines three methods as 
follows: 
 
    Method max (int x, int y, int z) determines and returns the maximum value of three integer values. 
    Method min (int X, int y, int z) determines and returns the minimum value of three integer values. 
    Method average (int x, int y, int z) determines and returns the average of three integer values. 
 
Test the methods with different input value read from the user (in the main method).  
 
Design the main method of your program such that it allows the user to re-run the program with different inputs 
(i.e., use a loop structure). Document your code, and organize and space the outputs properly. Use escape 
characters to organize the outputs. Sample output is: 
 
You entered:    20  8  12 
Max value:      20 
Min value:     8 
Average value:  13.33333333333 
 
Exercise 2: Design and implement a Java program (name it ComputeAreas) that defines four methods as 
follows: 
 
    Method squareArea (double side) determines and returns the area of a square. 
    Method rectangleArea (double width, double length) determines and returns the area of a rectangle. 
    Method circleArea (double radius) determines and returns the area of a circle. 
    Method triangleArea (double base, double height) determines and returns the area of a triangle. 
  
Test the methods with different input value read from the user (in the main method).  
 
Design the main method of your program such that it allows the user to re-run the program with different inputs 
(i.e., use a loop structure). Document your code, and organize and space the outputs properly. Use escape 
characters to organize the outputs. Sample outputs, for shape types selected by the user, are: 
 
 
Square Side =  5.1 
Square Area =  26.01 
 
Rectangle Width =  4.0 
Rectangle Length = 5.5 
Rectangle Area =  22.0 
 
Circle Radius =  2.5 
Circle Area =  19.625 
 
Triangle Base =  6.4 
Triangle Height =  3.6 
Triangle Area =  11.52 
 
 
 
 
 
 
Page 2 of 2 
 
Next Page  
 
Exercise 3: Design and implement a Java program for programming exercise 6.3, page 234 (name it 
PalindromeInteger), to check if an integer value is a palindrome or not, using 2 methods (reverse and 
isPalindrome) specified in the problem statement. Follow the instructions in the problem statement. Design 
the main method of your program such that it allows the user to re-run the program with different inputs (i.e., use 
a loop structure). Document your code, and organize and space the outputs properly using escape characters. 
 
 
Exercise 4: Design and implement a Java program for programming exercise 6.11, page 236 (name it 
ComputeCommissions), to print out table of sales amount and commission as shown in the textbook. Follow 
the instructions in the problem statement. Document your code, and organize and space the outputs as shown 
in the textbook using escape characters. 
 
 
Submission: 
 
1.  Save all programs. 
2.  Check with your instructor for submission instructions.