【文章內(nèi)容簡介】
uble parameters ? (The maximum between , , and is ? + max(, , ))。 ? } 例 max方法 ? // Find the max between two int values ? static int max(int num1, int num2) ? { ? if (num1 num2) ? return num1。 ? else ? return num2。 ? } ? ? // Find the max between two double values ? static double max(double num1, double num2) ? { ? if (num1 num2) ? return num1。 ? else ? return num2。 ? } ? ? ?// Find the max among three double values ? static double max(double num1, double num2, double num3) ? { ? return max(max(num1, num2), num3)。 ? } ?} 方法 說明 方法 說明 abs(x) x的絕對值 (這個方法還有float,int和 long型值的版本 ) max(x,y) 取 x和 y中較大者。 ceil(x) 不小于 x的最小整數(shù) (向上取整) min (x,y) 取 x和 y中較小者。 cos(x) x的余弦函數(shù)值 (x以弧度為單位 ) pow (x,y) x的 y次冪 exp(x) 指數(shù)方法 e的 x次冪 sin (x) x的正弦函數(shù)值 (x以弧度為單位 ) floor(x) 不大于 x的最大整數(shù) (向下取整) sqrt (x) x的平方根 log(x) x的自然對數(shù) (以 e為底 ) ? random() Returns a random double value in the range [, ). ? cos(double a) ? tan(double a) ? acos(double a) ? asin(double a) ? atan(double a) ? Class constants: ?PI ?E 例 ? public class ComputeMeanDeviation ? { ? // Main method ? public static void main(String[] args) ? { ? int number = 0。 // Store a random number ? double sum = 0。 // Store the sum of the numbers ? double squareSum = 0。 // Store the sum of the squares ? 計算 ? 輸出 ? } ? } 例 ? 計算 ? for (int i=0。 i10。 i++) ? { ? // Generate a new random number ? number = (int)(()*1000)。 ? (number)。 ? ? // Add the number to sum ? sum += number。 ? ? // Add the square of the number to squareSum ? squareSum += (number, 2)。 // Same as number*number。 ? } ? // Find mean ? double mean = sum/10。 ? // Find standard deviation ? double deviation = ((squareSum mean)/(10 1))。 例 ? 輸出 ? // Display result ? (The mean is + mean)。 ? (The standard deviation is + deviation)。 例 ? public class PrintCalendar ? { ? // Main method ? public static void main(String[] args) ? { ? // The user enters year and month ? (Enter full year: )。 ? int year = ()。 ? (Enter month in number between 1 and 12: )。 ? int month = ()。 ? ? // Print calendar for the month of the year ? printMonth(year, month)。 ?