게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
자바 계절학기 문젠데 안되는것이 있어 질문드립니다
게시물ID : programmer_7637짧은주소 복사하기
작성자 : Nopl
추천 : 0
조회수 : 453회
댓글수 : 2개
등록시간 : 2015/01/15 12:49:24
옵션
  • 본인삭제금지

public class test02 {
  static int Add(int a, int b){
   return a+b;
 }
  static int Sub(int a, int b){
   return a-b;
 }
  static int Mul(int a, int b){
   return a*b;
 }
  static int Div(int a, int b){
   return a/b;
 }
  public static void main(String[] args) {
   
   int a=0; int b=0; String c="";
   for (int i=0;i<args.length;i++){
     a = Integer.parseInt(args[0]);
     c = args[1];
     b = Integer.parseInt(args[2]);
    
   }
   if (c.equals("+")){
   
    System.out.println( Add(a,b));
   
  }
  else if (c.equals("-")){
   
    System.out.println( Sub(a,b));
   
  }
  else if (c.equals("*")){
    System.out.println( Mul(a,b));
   
  }
  else if (c.equals("/")){
    System.out.println( Div(a,b));
   
  }
  else 
   System.out.println("잘못 입력되었습니다.");
  
  

}
}
  


메인메소드 인자를 받아서 돌아가는 프로그램인데

딴건다 잘되는데 곱셈을 하면 오류가 나네요  왜이것만 오류가나는걸까요 
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호