| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- gitlab 연동
- GitHub Mirroring
- settings sync
- GitLab미러링
- code 설치
- Path Alias
- 유니옥션
- webstorm
- 티스토리초대
- GitLab Mirroring
- 네이버 클라우드 플랫폼
- GitHub 미러링
- Emmet
- react native #gradle
- 프레시업 #풀무원 #하루한병 #건강만들기 #풀무원 녹즙
- code .
- visual studio code
- currentTimeMillis
- React Native
- 프리티어
- 실행시간 측정
- code 세팅
- visual studio code cli
- 초대장
- 티스토리 초대장/ 티스토리초대
- '티스토리 초대장/ 티스토리초대'
- 티스토리 초대장
- 니돈내먹
- 음료같은녹즙
- eslint-import-resolver-typescript
Archives
- Today
- Total
방치하기
Calclulator 핵심은 스캐너 겠지 . 본문
반응형
import java.util.*;
class Calc
{
public int a,b;
public Calc(int a,int b){
this.a=a;
this.b=b;
}
public void option(String opt)
{
if (opt.equals("+"))
{
this.plus();
}
else if (opt.equals("-"))
{
this.minus();
}
else if (opt.equals("/"))
{
this.nanum();
}
else if (opt.equals("*"))
{
this.gob();
}
else
{
}
}
public void plus()
{
System.out.printf("더한 결과 :%d\n",this.a+this.b);
}
public void minus()
{
System.out.printf("뺀 결과 :%d\n",this.a-this.b);
}
public void nanum()
{
System.out.printf("나누기 결과 :%d\n",this.a/this.b);
}
public void gob()
{
System.out.printf("곱한 결과 :%d\n",this.a*this.b);
}
}
class Calculator
{
public static void main(String [] args){
Scanner scan= new Scanner(System.in);
System.out.println("숫자 1입력 해주세요");
int a=scan.nextInt();
System.out.println("숫자 2입력 해주세요");
int b=scan.nextInt();
System.out.println("연산자를 입력 해주세요");
String c=scan.next();
Calc jh=new Calc(a,b);
jh.option(c);
}
}
반응형
'홍익대 Java > 과제' 카테고리의 다른 글
| 홍대 자바 수업:계산기 임 깜박하고 int로해서 소수점안됨 시간도 늦어서 그냥 제출 (0) | 2009.07.29 |
|---|---|
| 학생 3명 객체 생성후 . 과목 3개 값 대입 하고 평균 구해주고 석차 순위대로 출력(야매.. 정식 은 조만간 올리겠음) 덤으로 버그도 있다 . 토탈이 같을경우는 문제가 발생한다 ㅎ 고치기 귀찮아서 그냥 했을뿐 (0) | 2009.07.21 |
| 현금 입출기 (0) | 2009.07.18 |
| in.read in.skip 사칙 연산자 (0) | 2009.07.16 |
| 주민 번호님 인수로 받아서 남녀 구별해주기 .substring (0) | 2009.07.16 |
Comments