티스토리 뷰
package javaapplication7;
public class JavaApplication7 {
public static void main(String[] args)
{
Calculator cal=new Calculator(10);
cal.Add(10);
cal.Subtract(3);
cal.Divide(4);
cal.Multiply(3);
cal.Factorial();
cal.Module(13);
cal.Power(3);
System.out.println("계산 결과 : "+ cal.GetResult());
}
class Calculator
{
private long m_result;
public Calculator(){}
public Calculator(int n)
{
m_result=n;
}
public long Add(int n)
{
m_result=m_result+n;
return m_result;
}
public long Subtract(int n)
{
m_result=m_result-n;
return m_result;
}
public long Divide(int n)
{
m_result=m_result/n;
return m_result;
}
public long Multiply(int n)
{
m_result=m_result*n;
return m_result;
}
public long Factorial()
{
for(int i=1;i<=m_result;i++)
m_result*=i;
return m_result;
}
public long Module(int n)
{
m_result=m_result%n;
return m_result;
}
public long Power(int n)
{
for(int i=1;i<=n;i++)
m_result*=m_result;
return m_result;
}
public long GetResult()
{
return m_result;
}
}
}
'IT Skills > Programming' 카테고리의 다른 글
C# - 동물농장 참고자료#2 (0) | 2013.04.22 |
---|---|
C# - 시험참고자료#` (0) | 2013.04.22 |
C#-수강신청 (0) | 2013.04.10 |
Linux vi편집기 사용법(한글깨짐오류처리방법포함)&&telnet 기본적인 사용법 (0) | 2013.04.02 |
JAVA - 오목 만들어보기 2 (0) | 2013.04.01 |
- Total
- Today
- Yesterday
- 보스
- 플스2
- 듀얼쇼크4
- 노트북
- 피규어
- AMD
- 구글
- m5a97
- 프라모델
- 아이폰X
- 일본
- 프로그래밍
- Asus
- 일본여행
- 마우스
- 이어폰
- razer
- ps4
- javascript
- PS2
- 윈도우즈 10
- 안산
- 애드센스
- 카카오프렌즈
- 디지바이스
- 라이언
- 건담
- 디지몬
- 고양이
- Windows 10
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |