Java Ex2
這次作業寫得很有成就哼哼,因為她媽根本沒教陣列要我們用陣列QQ喔。
作業要求如下:
Requirements:
- Write a program that read a sequence of integer inputs of test scores. Scores are separated by
- The score input has a sentinel of -1 for
- Decompose each task into a method, for example: minScore(scores); maxScore(scores);
……
- Write a method
Public static returnType minScore(dataType parameterVar)
that returns the minimum score in the input sequence.
- Write a method
Public static returnType maxScore(dataType parameterVar)
that returns the maximum score in the input sequence.
- Write a method
Public static returnType avgScore(dataType parameterVar)
that returns the round average score in the input sequence.
- Write a method
Public static returnType numOfNinety(dataType parameterVar)
that returns the number of scores that greater and equal to 90.
- Write a method
Public static returnType adjacentDIff(dataType parameterVar)
that returns a Boolean.
If the input scores are getting higher and higher,
show System.out.println(“Scores improving!”);
if not, show System.out.println(“Scores NOT improving!”)
- (extra) Write a method
Public static returnType stdDeviation(dataType parameterVar)
that returns the amount of variation of the input values.
- (extra) Write a method
Public static returnType squareRoot(dataType parameterVar)
that returns the square root of the argument value.
Assume y2 = a, return y when pass a to the squareRoot method.
In your program, call the squareRoot method and perform average score adjustment. For example, if the average score is 87, the score adjustment is √87 *10 = 93.
- Generate complete Javadoc (e.g. import statement, class, method, comments, etc.) for the class. For example,
/**
Computes the volume of a cube.
@param sideLength the side length of the cube
@return the volume
*/
public static double cubeVolume(double sideLength)
- Do NOT hard-code the output.
- The class Math in util.Math is NOT allowed.
結果如下:
扣掉基本要求以外,額外要求是可以計算標準差跟平方根。
但我以為可以直接^(0.5),但結果必須引用Math(題目不許)的方法才行,所以最後只好用很白癡的十分逼近法去乘。