728x90
import java.util.Scanner;
class shape
{
double ban(int a){return a*a*3.14;}
int quare(int a, int b){return a*b;}
}
public class scan
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
shape se = new shape();
int a=1, b=1;
while(true)
{
System.out.print("도형을 선택하시오.(1:원, 2:정사각형, 3:종료) : ");
int menu = sc.nextInt();
switch(menu)
{
case 1:
System.out.print("원의 반지름을 입력하시오. : ");
int r=sc.nextInt();
System.out.println("원의 넓이는 "+se.ban(r)+"입니다.");
break;
case 2:
System.out.print("사각형의 두 변의 길이를 입력하시오. : ");
int l1=sc.nextInt();
int l2=sc.nextInt();
System.out.println("사각형의 넓이는 "+se.quare(l1,l2)+"입니다.");
break;
case 3:
System.out.println("종료합니다.");
return;
}
}
}
}'it > programming' 카테고리의 다른 글
| [JAVA] 메소드와 생성자를 이용한 가상 DB 관리 (0) | 2013.04.17 |
|---|---|
| [JAVA] 객체 프로그래밍 (0) | 2013.04.03 |
| [HTML] audio, video태그와 input태그 실습 (0) | 2013.03.28 |