JAVA에서 do~while문 예제
- OS & Program/JAVA
- 2010. 7. 29. 01:11
*** 검색어: nabiro, java, do, while, example, sample, 예제
// do~while문 예제
import java.io.*;
public class P179 {
public static void main(String[] ar) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int a=0, b=0, c=0, total=0;
char point=0;
float avg=0.0f;
do {
System.out.print("a=");
a=Integer.parseInt(in.readLine());
} while (a < 0 || a >100);
do {
System.out.print("b=");
b=Integer.parseInt(in.readLine());
} while (b < 0 || b >100);
do {
System.out.print("c=");
c=Integer.parseInt(in.readLine());
} while (c < 0 || c >100);
total = a + b + c;
avg = total / 3.0f;
switch((int)(avg / 10)) {
case 10:
case 9: point = 'A'; break;
case 8: point = 'B'; break;
case 7: point = 'C'; break;
default : point = 'D';
}
System.out.println("Total=" + total);
System.out.println("Avg=" + avg);
System.out.println("Point=" + point);
}
}
'OS & Program > JAVA' 카테고리의 다른 글
| JAVA 배열 초기화 예제 (0) | 2010.08.02 |
|---|---|
| eclipse 실행 시에 매개 변수 전달하는 방법 (0) | 2010.08.02 |
| Java에서 while문 예제 (0) | 2010.07.29 |
| JAVA에서 switch ~ case문 예제 (0) | 2010.07.28 |
| JAVA에서 문자열 입력 및 if 조건문 예제 (0) | 2010.07.28 |