Skip to main content

원기둥 부피와 표면적 계산

#


#

package pro_04_08;

 

import java.util.Random;

 

public class CalculateVolume {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

final double PI = 3.14159;

int radius;

double volume, height, area;

Random generator = new Random();

radius = generator.nextInt(10)+1;

height = generator.nextInt(10)+1;

volume = PI * radius * radius * height;

area = 2 * PI * radius * height;

System.out.println("반지름 = " + radius);

System.out.println("원기둥 = " + height);

System.out.println("부피 = " + volume);

System.out.println("표면적 = " + area)




#


Comments