
package Chapter02;
import java.util.Scanner;
public class exercise24 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("원기둥 밑변의 반지름을 입력하시오.(단위:cm): ");
double num1 = scanner.nextDouble();
System.out.print("원기둥의 높이를 입력하시오.(단위:cm): ");
double num2 = scanner.nextDouble();
double result = num1 * num1 * Math.PI;
System.out.println("원기둥 밑변의 넓이는: " + result + "㎠" + "이고, ");
double result1 = result * num2;
System.out.println("원기둥의 부피는: " + result1 + "㎠" + "이다.");
}
}
'Java > 과제' 카테고리의 다른 글
chapter03) 연산자 example - 2가지 조건 중 하나를 만족할 때 문구가 나타나는 프로그램 (0) | 2022.08.07 |
---|---|
chapter03) 연산자 example - 두 정수를 입력 받아 큰 수를 작은 수로 나눈 몫과 나머지를 출력하는 프로그램 (0) | 2022.08.07 |
chapter02) 변수와 타입 example - 저금통 안에 총 얼마가 들어있는지 출력하는 프로그램 (0) | 2022.08.07 |
chapter02) 변수와 타입 example - 빛의 속도로 도착하는 데 걸리는 시간 (0) | 2022.08.07 |
chapter02) 변수와 타입 example - 직사각형의 둘레와 면적을 구하는 프로그램 (0) | 2022.08.07 |