티스토리 뷰
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
- ps4
- 노트북
- 애드센스
- 피규어
- m5a97
- Windows 10
- 마우스
- 카카오프렌즈
- Asus
- AMD
- 디지바이스
- 보스
- 아이폰X
- 프라모델
- 안산
- 일본
- 라이언
- PS2
- 이어폰
- 듀얼쇼크4
- 윈도우즈 10
- 고양이
- 구글
- razer
- 프로그래밍
- 디지몬
- 건담
- 일본여행
- 플스2
- javascript
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |