자바 애플릿(JAVA Applet)을 이용해 계산기 구현하기
본 자료는 5페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
해당 자료는 5페이지 까지만 미리보기를 제공합니다.
5페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

자바 애플릿(JAVA Applet)을 이용해 계산기 구현하기에 대한 보고서 자료입니다.

목차

1. 분석
1) 문제
2) 문법 (V)
3) 가정 (V)
4) 설계
1-4-1. 전체구조
1-4-2. 함수별기능
1-4-3. 알고니즘

2. 코딩

* (V)표시되어 있는건 프로그래밍 언어론을 배우시는 분들에게 필요한 내용이므로 단순히 JAVA프로그래밍을 들으시는 분들에게는 필요 없는 내용입니다.

본문내용

se '(' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = -1; break;
case ')' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = 0; break;
case '+' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = 5; break;
case '-' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = 4; break;
case '*' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = 3; break;
case '/' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = 2; break;
case '^' : j++ ; abeq.append(comeq.charAt(i)) ;
sta[2][j] = i; sta[1][j] = 1; break;
}
}
/* 층번호 구하기 */
sta[0][0] = 1;
for (int i=1; i < abeq.length(); i++)
{
if (abeq.charAt(i) == ')')
{
if (abeq.charAt(i-1) == '(')
sta[0][i] = sta[0][i-1];
else sta[0][i] = sta[0][i-1]-1;
}
else
{
if (abeq.charAt(i-1) == '(')
sta[0][i] = sta[0][i-1]+1;
else sta[0][i] = sta[0][i-1];
}
}
return sta ; // str을 return한다
}
/* 배열의 i-번째 원소 앞에 그 i-번째 원소값보다 작은 값을 갖는
원소의 수를 구하는 메쏘드 */
private static int howMany(int[][] st0, int i)
{
int count=0;
for (int j=0; j < i; j++)
{
if (st0[j][2] }
return count ;
}
/* 구조배열로부터 계산순서배열 구하는 메쏘드 */
private static int[][] getStep(int[][] sta)
{
int dim = sta[0].length;
int[][] st0 = new int[dim][3];
int[][] st = new int[dim][2];
// st0 구하기
for (int i=0; i {
st0[i][0] = sta[0][i] ;
st0[i][1] = sta[1][i] ;
st0[i][2] = i ;
}
int[] temp = new int[3];
// step 구하기
for (int i=1; i {
int j=i;
while (st0[j][0] > st0[j-1][0] | (st0[j][0] == st0[j-1][0] & st0[j][1] < st0[j-1][1]) )
{
temp = st0[j-1];
st0[j-1]=st0[j];
st0[j]=temp;
if (j>1) j--;
}
}
// st 배열 구하기
for (int i=0; i {
st[i][0] = st0[i][1] ;
st[i][1] = st0[i][2] - howMany(st0, i);
}
return st; // st값 반환
}
public String calculate(String eq)
{
String comeq = compactify(eq) ; // 수식의 공백문자 제거
int[][] sta = getStructureArray(comeq) ; // 구조배열 구하기
if (sta == null)
return eq; // 연산자가 없을 때
int[][] st = getStep(sta) ; // 계산순서배열 구하기
/* 피연산자 배열 정의 */
int dim = st.length;
String[][] opnd = new String[dim+1][];
for (int d = 0; d < dim+1 ; d++)
{
opnd[d] = new String[dim+1-d];
}
/* 계산과정 */
/* 1. 피연산자 초기화 */
opnd[0][0]=comeq.substring(0,sta[2][0]) ;
for (int i=1; i < dim; i++)
{
opnd[0][i]=comeq.substring(sta[2][i-1]+1,sta[2][i]) ;
}
opnd[0][dim]=comeq.substring(sta[2][dim-1]+1) ;
/* 2. 계산 수행 */
for (int i=0; i {
if (st[i][0] == -1)
{
opnd[i+1][st[i][1]] = Calculator_1.apply(opnd[i][st[i][1]+1],opnd[i][st[i][1]],st[i][1]) ;
}
else if (st[i][0] == 0 )
{
opnd[i+1][st[i][1]] = opnd[i][st[i][1]] ;
}
else if (st[i][0] != -1 & st[i][0] != 0)
opnd[i+1][st[i][1]] = Calculator_1.apply(opnd[i][st[i][1]],opnd[i][st[i][1]+1],st[i][0]) ;
for (int j=0; j {
opnd[i+1][j] = opnd[i][j] ;
}
for (int k=st[i][1]+1; k {
opnd[i+1][k] = opnd[i][k+1] ;
}
}
/* 3. 최종 결과 */
return opnd[dim][0] ; // opnd[dim][0]값 반환
}
}

키워드

자바,   애플릿,   JAVA,   Applet,   계산기,   소스
  • 가격2,000
  • 페이지수16페이지
  • 등록일2004.11.28
  • 저작시기2004.11
  • 파일형식한글(hwp)
  • 자료번호#275859
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니