본문 바로가기

Technote/JAVA25

9주차 1번문제 P9_1 강의자료에 나오는 ButtonTester 프로그램을 수정하여 버튼이 클릭될 때마다 "I was clicked 1 time(s)!", "I was clicked 2 time(s)!", "I was clicked 3 time(s)!" ... 메시지가 콘솔창에 프린트되게 하시오. (힌트: ActionListener 객체가 count를 위한 필드를 갖도록 하면 됩니다.) ButtonTester package p9_1; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class ButtonTester { /** * @param args */ public static void .. 2009. 5. 9.
JAVA 4주차 P4.1 아래 문자열을 화면에 출력하고 키보드로부터의 입력을 받아들이는 동작을 반복하되 키보드 입력이 Q나 q이면 반복 동작을 마치고 그 때까지 입력된 단어들을 모두 연결하여 화면에 출력하는 프로그램을 작성하시오. 단어를 입력하고 엔터를 누르시오. 마치려면 Q(q) 입력: import java.util.Scanner; public class boxtester { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); boolean done = false; String s = ""; System.out.print("Enter value, Q to quit: "); int i; while.. 2009. 3. 25.
JAVA 3주차 1. box.classpublic class box {private int length, width, height;public void setLength(int p){length = p;}public void setWidth(int p){width = p;}public void setHeight(int p){height = p;}public int displayVolume(){System.out.println(length*width*height); return (length*width*height);}}boxtester.classpublic class boxtester {/** * @param args */public static void main(String[] args) {box b1 = new bo.. 2009. 3. 25.
JAVA 1주차 1. FILE name : copyandpast.class public class copyandpast { public static void main(String[] args) { System.out.print("Myfavorite number is"); System.out.println("1+2+3"); } } 2. 1+2+3+4+5를 계산하여 결과를 화면에 보여주는 프로그램을 작성하시오 FILE name : copyandpast.class public class copyandpast { public static void main(String[] args) { System.out.println(1+2+3+4+5); } } 3. public class copyandpast { public static v.. 2009. 3. 25.