123

실습과제 모음 2012. 11. 3. 17:16 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;


class MyFrame extends JFrame {

JButton bu;

ImageIcon icon1;

ImageIcon icon2;

ImageIcon icon3;


MyFrame() throws InterruptedException {

bu = new JButton();

icon1 = new ImageIcon("1.png");

icon2 = new ImageIcon("2.png");

icon3 = new ImageIcon("3.png");

setSize(600, 400);

setVisible(true);

JPanel panel = new JPanel();

panel.add(bu);

add(panel);

showImage();

}

public void showImage() throws InterruptedException {

bu.setIcon(icon1);

Thread.sleep(1000);

bu.setIcon(icon3);

}

}


public class CircleTest extends JFrame {

public static void main(String[] args) throws InterruptedException {

MyFrame ct = new MyFrame();

}

}


'실습과제 모음' 카테고리의 다른 글

C 언어 실습문제 모음  (0) 2013.01.09
CPP 실습과제 1208  (0) 2012.12.08
[JAVA1] 2012-10-14 실습 #2  (0) 2012.10.14
[JAVA1] 2012-10-14 실습 #1  (0) 2012.10.14
CPP 실습  (0) 2012.09.22
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

'Programming > C,CPP,CS' 카테고리의 다른 글

C언어 달력소스코드  (0) 2013.01.13
C 실습과제  (0) 2012.11.17
CPP 예외처리  (0) 2012.09.23
C언어 정렬 알고리즘 예제  (0) 2012.08.26
C 달력 소스코드  (2) 2012.07.23

[JAVA1] 2012-10-14 실습 #2

실습과제 모음 2012. 10. 14. 16:15 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

1. x! x를 입력받아 팩토리얼을 구하라.

 

2. x를 입력받아 1~x 중의 제일 큰 소수를 구하라.

(소수 : 1과 자기자신으로만 나누어 떨어지는 수)

 

3. 두 수를 입력받아 최소공배수를 구하라.

 

4. 두 수를 입력받아 최대공약수를 구하라.

 

5. 달력을 출력하라

 

 

'실습과제 모음' 카테고리의 다른 글

CPP 실습과제 1208  (0) 2012.12.08
123  (0) 2012.11.03
[JAVA1] 2012-10-14 실습 #1  (0) 2012.10.14
CPP 실습  (0) 2012.09.22
CPP 게임 실습  (0) 2012.09.22

[JAVA1] 2012-10-14 실습 #1

실습과제 모음 2012. 10. 14. 16:01 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

1.     조건문

A.     if, if else, else if, switch

                         i.         두 수를 입력 받아 두 수 중 큰 수를 출력하는 프로그램

                       ii.         두 수와 연산자(+,-,*,/) 를 입력 받아 두 수와 연산자와의 연산 결과를 출력하는 프로그램

2.     반복문

A.     for, while, do while

                         i.         정수를 입력 받아 정수만큼 * 를 출력하는 프로그램

1.      예제 1

A.     입력 : 3

B.      출력
***

2.      예제 2

A.     입력 : 5

B.      출력
*****

                       ii.         정수를 입력 받아 정수만큼 *로 삼각형을 출력하는 프로그램

1.      예제 1

A.     입력 : 3

B.      출력
*
**
***

2.      예제 2

A.     입력 : 5

B.      출력
*
**
***
****
*****

                      iii.         정수를 입력 받아 정수만큼 *로 피라미드를 출력하는 프로그램

1.      예제 1

A.     입력 : 3

B.      출력
  *       2
 ***      1
*****    0

2.      예제 2

A.     입력 : 5

B.      출력
    *    4
   ***   3
  *****  2
 ******* 1
*********0

                      iv.         정수를 입력 받아 정수만큼 *로 다이아몬드를 출력하는 프로그램

1.      예제 1

A.     입력 : 3

B.      출력
  *
 ***
*****
 ***
  *

2.      예제 2

A.     입력 : 5

B.      출력
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *

'실습과제 모음' 카테고리의 다른 글

123  (0) 2012.11.03
[JAVA1] 2012-10-14 실습 #2  (0) 2012.10.14
CPP 실습  (0) 2012.09.22
CPP 게임 실습  (0) 2012.09.22
C언어 실습문제 0811  (0) 2012.08.11

CPP 예외처리

Programming/C,CPP,CS 2012. 9. 23. 15:39 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include <iostream>

#include <string>

#include <exception>

using namespace std;

class UserException : public logic_error

{

public:

    int num1;

    int num2;

    UserException(const int num1, const int num2)

        : logic_error("잘못된인수값")

    {

        this->num1 = num1;

        this->num2 = num2;

    }

    int getNum1(){ return num1; }

    int getNum2(){ return num2; }

};

int divide(int n1, int n2)

{

    UserException ue(n1, n2);

    if( n2 == 0 )

        throw ue;

    int result = n1 / n2;

    return result;

}

 

int main()

{

    int n1, n2;

    cout << ": ";

    cin >> n1;

    cout << ": ";

    cin >> n2;

    try

    {

        cout << divide(n1, n2);

    }

    catch(UserException n)

    {

        cout << "0으로나눌수없습니다." << endl;

        cout << "n1 = " << n.getNum1() << endl;

        cout << "n2 = " << n.getNum2() << endl;

    }  

    return 0;

}

 

 

 

'Programming > C,CPP,CS' 카테고리의 다른 글

C 실습과제  (0) 2012.11.17
프로그래밍 경진대회 관련 사이트  (0) 2012.10.14
C언어 정렬 알고리즘 예제  (0) 2012.08.26
C 달력 소스코드  (2) 2012.07.23
CPP 달력 소스코드  (0) 2012.07.21