1. 아래 함수를 만드시오.
double area = getCircleArea(10);
System.out.println(area);
area = getRectangleArea(10,20);
System.out.println(area);
area = getTriangleArea(40,20);
System.out.println(area);
int code = getAscCode('A');
System.out.println(code);
public class MethodExamples {
public static void main(String[] args) {
double area = getCircleArea(10);
System.out.println(area);
area = getRectangleArea(10, 20);
System.out.println(area);
area = getTriangleArea(40, 20);
System.out.println(area);
int code = getAsciiCode('A');
System.out.println(code);
}
static int getAsciiCode(char ch) {
return (int)ch;
}
static double getTriangleArea(int w, int h) {
return 0.5*w*h;
}
static double getRectangleArea(int x, int y) {
return x*y;
}
static double getCircleArea(int r) {
final double PI = 3.14;
return r*r*PI;
}
}
314.0
200.0
400.0
65