±Û¾´ÀÌ :±èÇÊÈ£ 1998³â 11¿ù 17ÀÏ 23:20:33
In Reply to: DataInputStream À» ½á¼.... posted by ±èÇÊÈ£ on 1998³â 11¿ù 17ÀÏ 22:12:52:
Integer.parseInt() ¶§¹®¿¡ ¿¹¿Ü 󸮰¡ ÇÊ¿äÇÕ´Ï´Ù.
// ------------------
// Grade.java
// ------------------
import java.io.*;
public class Grade {
public static void main(String args[])throws IOException {
DataInputStream in = new DataInputStream(System.in);
char grade=' ';
int score;
try {
System.out.println("----[ ÀÔ·Â ]----");
score = Integer.parseInt(in.readLine());
if(score>=90){
grade='A';}
else if(score>=80){
grade='B';}
else if(score>=70){
grade='C';}
else if(score>=60){
grade='D';}
else{
grade='F';}
System.out.println("----[ °á°ú ]----");
System.out.println("Á¡ ¼ö: "+score);
System.out.println("ÇÐ Á¡: "+grade);
}
catch (NumberFormatException ex) {
System.err.println("Error: NumberFormatException occurs in parsing integer.");
}
}
}