336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

지역 : 천안, 아산, 청주


종목 : 프로그래밍, 정보올림피아드, CCNA, CCNP


경력 : 지도학생) 2013 초등부 정보올림피아드 전국대회 은상 수상

         전) 서울 서울특별시립종합직업전문학교 외부강사

         전) 천안 그린컴퓨터학원 프로그래밍 강사


         현) 청주 그린컴퓨터학원 프로그래밍 강사

         현) 아산소재 대학교 시간강사

         현) 천안소재 대학교 시간강사

         현) 대학원 박사과정 재학중




자세한 문의는


tansanc23@gmail.com 으로 문의해 주세요.

공일공-구구육이-일사일칠



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

 

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTextField;

 

class MyFrame extends JFrame {

   private JButton button;

   private JTextField text, result;

 

   public MyFrame() {

       setSize(300, 130);

       setTitle("제곱 계산하기");

   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 

       ButtonListener listener = new ButtonListener(); // 리스너 객체 생성

 

       JPanel panel = new JPanel();

       panel.add(new JLabel("숫자 입력: ")); // 레이블 생성

       text = new JTextField(15); // 컬럼수가 15 텍스트 필드 생성

       text.addActionListener(listener); // 텍스트 필드에 리스너 연결

       panel.add(text);

 

       panel.add(new JLabel("제곱한 : "));

       result = new JTextField(15); // 결과를 나타낼 텍스트 필드

       result.setEditable(false); // 편집 불가 설정

       panel.add(result);

       button = new JButton("OK");

       button.addActionListener(listener);

       panel.add(button);

       add(panel);

       setVisible(true);

   }

 

   // 텍스트 필드와 버튼의 액션 이벤트 처리

   private class ButtonListener implements ActionListener {

       public void actionPerformed(ActionEvent e) {

          if (e.getSource() == button || e.getSource() == text) {

             String name = text.getText();

             int value = 0;

             try {

                value = Integer.parseInt(name);

 

                 boolean isPrimeNumber = false;

 

                 // 계산

                 int count = 0;

                 for (int i = 1; i <= value; i++) {

                    // 계산

                    if (value % i == 0) {

                       count++;

                    }

 

                 }

 

                 if (count == 2) {

                    isPrimeNumber = true;

                 }

 

                 if (isPrimeNumber) {

                    result.setText("소수입니다.");

                 } else {

                    result.setText("소수가 아닙니다.");

                 }

            } catch (NumberFormatException e1) {

                 result.setText("숫자를 입력해주세요!!");

             }

             text.requestFocus();

          }

       }

   }

}

 

public class TextFieldTest extends JFrame {

   public static void main(String[] args) {

       new MyFrame();

   }

}

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 파일 검색 코드  (0) 2013.12.28
JAVA GUI 계산기 소스코드  (0) 2013.12.22
JAVA 소수를 판단하는 GUI 프로그램  (0) 2013.12.21
JAVA 버블 정렬  (0) 2013.11.30
JAVA JTable 실습 예제  (0) 2013.08.24

C 패턴 분석 프로그램

Programming/C,CPP,CS 2013. 12. 8. 11:07 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include <stdio.h>

 

int main()

{

   int i;

   int type  = -1;

   // 0 :

   // 1 : 부팅

   int s1 = 3;

   int s2 = 5;

   int s[2] = {3,5};

 

   char patternString[2][10] = {"",

       ""};

   char resultString[2][30] = {" 안하세",

      "탭이 켜져있나?"};

   char string[20];

   int j;


   gets(string);

 

   for( j = 0 ; j < 2; j++)

   {

       i = match(string,patternString[j]);

       // java : strstr

       if( i != -1)

       {

          type = j;

       }

   }

   if( type != -1 )

   {

       printf("%s\n", resultString[type]);

   }

   return 0;

}

 

int match(char text[], char pattern[]) {

  int c, d, e, text_length, pattern_length, position = -1;

 

  text_length    = strlen(text);

  pattern_length = strlen(pattern);

 

  if (pattern_length > text_length) {

    return -1;

  }

 

  for (c = 0; c <= text_length - pattern_length; c++) {

    position = e = c;

 

    for (d = 0; d < pattern_length; d++) {

      if (pattern[d] == text[e]) {

        e++;

      }

      else {

        break;

      }

    }

    if (d == pattern_length) {

      return position;

    }

  }

 

  return -1;

}

 

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

Visual Studio 2010 Express Version  (0) 2013.12.28
측정값 오류 찾기 + 파일 입출력  (0) 2013.12.08
C언어 달력 소스코드  (0) 2013.08.02
아스키코드표  (0) 2013.05.02
프로그래밍용으로 좋은 폰트  (0) 2013.03.23

JAVA 계산기 프로그램 부분완성

Programming/JAVA,JSP 2013. 8. 16. 14:25 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tansanc.tistory;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JTextField;

class Cal extends JFrame
{

	private JTextField t1;

	private JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, b0;

	JButton pl, mi, mu, di, cal, c;

	String x, y;

	public Cal()
	{

		setSize(285, 350);

		setDefaultCloseOperation(EXIT_ON_CLOSE);

		setTitle("Calculator");

		JPanel p = new JPanel();

		p.setLayout(null);

		t1 = new JTextField(10);

		p.add(t1);

		b1 = new JButton("1");

		p.add(b1);

		b1.addActionListener(new Number());

		b2 = new JButton("2");

		p.add(b2);

		b2.addActionListener(new Number());

		b3 = new JButton("3");

		p.add(b3);

		b3.addActionListener(new Number());

		b4 = new JButton("4");

		p.add(b4);

		b4.addActionListener(new Number());

		b5 = new JButton("5");

		p.add(b5);

		b5.addActionListener(new Number());

		b6 = new JButton("6");

		p.add(b6);

		b6.addActionListener(new Number());

		b7 = new JButton("7");

		p.add(b7);

		b7.addActionListener(new Number());

		b8 = new JButton("8");

		p.add(b8);

		b8.addActionListener(new Number());

		b9 = new JButton("9");

		p.add(b9);

		b9.addActionListener(new Number());

		b0 = new JButton("0");

		p.add(b0);

		b0.addActionListener(new Number());

		pl = new JButton("+");

		p.add(pl);

		pl.addActionListener(new Number());

		mi = new JButton("-");

		p.add(mi);

		mi.addActionListener(new Number());

		mu = new JButton("*");

		p.add(mu);

		mu.addActionListener(new Number());

		di = new JButton("/");

		p.add(di);

		di.addActionListener(new Number());

		cal = new JButton("=");

		p.add(cal);

		cal.addActionListener(new Number());

		c = new JButton("C");

		p.add(c);

		c.addActionListener(new Number());

		t1.setBounds(10, 10, 245, 80);

		b1.setBounds(10, 105, 45, 45);

		b2.setBounds(60, 105, 45, 45);

		b3.setBounds(110, 105, 45, 45);

		b4.setBounds(10, 155, 45, 45);

		b5.setBounds(60, 155, 45, 45);

		b6.setBounds(110, 155, 45, 45);

		b7.setBounds(10, 205, 45, 45);

		b8.setBounds(60, 205, 45, 45);

		b9.setBounds(110, 205, 45, 45);

		b0.setBounds(60, 255, 45, 45);

		pl.setBounds(160, 105, 45, 45);

		mi.setBounds(160, 155, 45, 45);

		mu.setBounds(160, 205, 45, 45);

		di.setBounds(160, 255, 45, 45);

		c.setBounds(110, 255, 45, 45);

		cal.setBounds(210, 105, 45, 195);

		add(p);

		setVisible(true);

	}

	String operand1;
	String operator;
	private class Number implements ActionListener
	{

		public void actionPerformed(ActionEvent e)
		{
			if( e.getSource() == b1)
			{
				t1.setText(t1.getText() + "1");
			}
			else if( e.getSource() == b2)
			{
				t1.setText(t1.getText() + "2");
			}
			else if( e.getSource() == pl)
			{
				operand1 = t1.getText();
				operator = "+";
				t1.setText("");
			}
			else if( e.getSource() == cal)
			{
				if(operator == "+")
				{
					t1.setText("" + ( Integer.parseInt(operand1) + Integer.parseInt(t1.getText())) );
				}
			}
		}
	}

}

public class CardTest
{

	public static void main(String[] args)
	{

		Cal Cals = new Cal();

	}

}

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 채팅 프로그램 소스  (0) 2013.08.23
JAVA 채팅 클라이언트  (0) 2013.08.23
JAVA 계산기 레이아웃  (0) 2013.08.16
JAVA 타자연습 프로그램  (0) 2013.08.13
JAVA Console Token 구현  (0) 2013.08.07

JAVA 타자연습 프로그램

Programming/JAVA,JSP 2013. 8. 13. 12:18 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tansanc.tistory;

import java.awt.BorderLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.Random;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

class MyFrame extends JFrame implements KeyListener
{
	JLabel staticText;
	JTextField inputText;
	JLabel resultText;
	long start;
	long end;
	String problemArray[] =
	{ "JAVA", "안녕하세요" };
	ArrayList problemList = new ArrayList();

	public MyFrame()
	{
		problemList.add("JAVA");
		problemList.add("안녕하세요");
		this.setSize(300, 200);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setTitle("이벤트 예제");
		staticText = new JLabel("Hello World");
		add(staticText, BorderLayout.NORTH);
		inputText = new JTextField("");
		add(inputText, BorderLayout.CENTER);
		resultText = new JLabel("Hello World");
		add(resultText, BorderLayout.SOUTH);

		inputText.addKeyListener(this);

		setVisible(true);
		start = System.currentTimeMillis();
	}

	@Override
	public void keyPressed(KeyEvent e)
	{
	}

	@Override
	public void keyReleased(KeyEvent e)
	{

	}

	@Override
	public void keyTyped(KeyEvent e)
	{
		if (staticText.getText().equals(inputText.getText()))
		{
			Random r = new Random();
			end = System.currentTimeMillis();
			resultText.setText("정답입니다. " + inputText.getText().length()
					/ ((end - start) / 1000.0 / 60.0));
			staticText.setText(problemList.get(r.nextInt(2)));
			inputText.setText("");
		}
	}
}

public class Test
{
	public static void main(String[] args)
	{
		MyFrame t = new MyFrame();
	}
}

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 계산기 프로그램 부분완성  (0) 2013.08.16
JAVA 계산기 레이아웃  (0) 2013.08.16
JAVA Console Token 구현  (0) 2013.08.07
JAVA 제네릭을 사용한 Store Class  (0) 2013.08.07
JAVA DRAG 가능한 Component 만들기  (0) 2013.08.03

JAVA 채팅 프로그램 + GUI

Programming/JAVA,JSP 2013. 2. 23. 12:11 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Chat 실습.zip

JAVA 채팅 프로그램 + GUI

 

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA 데이터베이스 실습 예제 UI  (0) 2013.02.24
JAVA JDBC 튜토리얼 예제 사이트  (0) 2013.02.24
RadioButton exam  (0) 2013.02.03
[IT]자바의 위기, 한국 IT의 시금석  (0) 2013.02.02
JAVA 비행기게임  (0) 2013.01.09
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#include <iostream>

#include <string>

using namespace std;

 

int main()

{

    string str;

    string tempStr[10];

    int tempStrSeq = 0;

    int tempStrCount[10] = {0};

    int start = 0, many = 0;

    getline(cin, str, '\n');

    for( int i = 0 ; i < str.length() ; i++ )

    {

        if( str.at(i) == ' ' || str.at(i) == ',' || str.at(i) == '.' )

        {

            if( many != 0)

            {

                cout << str.substr(start,many) << endl;

                int flag = 0;

                for( int j = 0 ; j < tempStrSeq + 1 ; j++ )

                {

                    if( tempStr[j].compare(str.substr(start,many)) == 0 )

                    {

                        flag++;

                        tempStrCount[j]++;

                    }

                    else

                    {

                        // 같지않다면

                    }

                }

                if( flag == 0)

                {

                    tempStr[tempStrSeq] = str.substr(start,many);

                    tempStrCount[tempStrSeq]++;

                    tempStrSeq++;

                }

                cout << "s : "<< start << "m : " << many << endl;

                many = 0;

            }

            start = i+1;

        }

        else

        {

            many++;

        }

    }

    if( many != 0)

    {

        cout << str.substr(start,many) << endl;

        int flag = 0;

        for( int j = 0 ; j < tempStrSeq + 1 ; j++ )

        {

           if( tempStr[j].compare(str.substr(start,many)) == 0 )

            {

                flag++;

                tempStrCount[j]++;

            }

            else

            {

                // 같지않다면

            }

        }

        if( flag == 0)

        {

            tempStr[tempStrSeq] = str.substr(start,many);

            tempStrSeq++;

            tempStrCount[tempStrSeq]++;

        }

        cout << "s : "<< start << "m : " << many << endl;

    }

 

    // TODO: 계산

 

    for( int i = 0 ; i < 10 ; i++ )

    {

        cout << tempStr[i] ;

        cout << " " << tempStrCount[i] << endl;

    }

}

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

아스키코드표  (0) 2013.05.02
프로그래밍용으로 좋은 폰트  (0) 2013.03.23
CPP string 줄단위 입력  (0) 2013.01.26
링크드리스트 학생관리  (0) 2013.01.19
C언어 달력소스코드  (0) 2013.01.13

CPP 표준체중 계산 프로그램

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

#include <iostream>

using namespace std;

class standardWeight

{

private:

   double  height, weight;

   int  WeightStatus;

public:

   void  setHeight(const double h);

   void  setWeight(const double w);

   double  getHeight();

   double  getWeight();

   int  StdWeight();

   int  getWeightStatus();

};

void  standardWeight::setHeight(const double h)

{

   height = h;

}

void  standardWeight::setWeight(const double w)

{

   weight = w;

}

double  standardWeight::getHeight()

{

   return height;

}

double  standardWeight::getWeight()

{

   return weight;

}

int  standardWeight::StdWeight()

{

   if(   (height - 100) * 0.9 < weight )

   {

       // 과체중

       WeightStatus = 1;

       return 1;

   }

   else if( (height - 100) * 0.9 > weight )

   {

       // 저체중

       WeightStatus = -1;

       return -1;

   }

   else

   {

       WeightStatus = 0;

       return 0;

   } 

}

int  standardWeight::getWeightStatus()

{

   return WeightStatus;

}

 

int main()

{

   standardWeight sw1;

   sw1.setHeight(170);

   sw1.setWeight(60);

   sw1.StdWeight();

   cout << sw1.getWeightStatus() << endl;

   return 0;

}

 

 

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

CPP 주말 과제 Time 클래스  (0) 2012.07.27
CPP ImaginaryNumber  (0) 2012.07.27
CPP 함수 실습과제  (0) 2012.07.25
CPP 함수 cvr, cba, cbv  (0) 2012.07.24
CPP 실습과제 0724 배열, 함수  (0) 2012.07.24