[6장 실습문제] 1. 다음 main( )이 실행되면 아래 예시와 같이 출력되도록 MyPoint 클래스를 작성하라. public class MyPoint { private int x; private int y; MyPoint (int x, int y) { this.x = x; this.y = y; } public String toString() { return "Point(" + x + "," + y + ")"; } public boolean equals (MyPoint mp) { if (this.x == mp.x && this.y == mp.y) return true; else return false; } public static void main(String[] args) { MyPoint p = new MyPoint.. withTextBook/명품 JAVA 프로그래밍 4년 전
[Chapter5_실습문제] [1~2] 다음 TV 클래스가 있다. 1. 다음 main( ) 메소드와 실행 결과를 참고하여 TV를 상속받은 ColorTV 클래스를 작성하라. class TV { private int size; public TV(int size) { this.size = size; } protected int getSize() { return size; } } public class ColorTV extends TV { private int color; public ColorTV(int size, int color) { super(size); this.color = color; } public void printProperty() { System.out.println(getSize() + "인치 " + color + ".. withTextBook/명품 JAVA 프로그래밍 4년 전
[Chapter4_실습문제] 1. 자바 클래스를 작성하는 연습을 해보자. 1. 다음 main( ) 메소드를 실행하였을 때 예시와 같이 출력되도록 TV 클래스를 작성하라. public class TV { public String name; public int year; public int inch; public TV (String name, int year, int inch) { this.name = name; this.year = year; this.inch = inch; } public void show () { System.out.println(this.name + "에서 만든 " + this.year + "년형 " + this.inch + "인치 TV"); } public static void main(String[] args.. withTextBook/명품 JAVA 프로그래밍 4년 전
[Chapter 3_실습문제] 1. 다음 프로그램에 대해 물음에 답하라. (1) 무엇을 계산하는 코드이며 실행 결과 출력되는 내용은? : 0부터 99까지 모든 짝수들을 더하는 코드이며, 실행 결과 2450이 출력됨. (2) 위의 코드를 main( ) 메소드로 만들고 WhileTest 클래스로 완성하라. public class WhileTest { public static void main(String[] args) { int sum = 0, i = 0; while (i < 100) { sum = sum + i; i += 2; } System.out.println(sum); } } (3) for 문을 이용하여 동일하게 실행되는 ForTest 클래스를 작성하라. public class ForTest { public static void .. withTextBook/명품 JAVA 프로그래밍 4년 전
[Chapter 2_실습문제] 1. Scanner 클래스를 이용하여 원화를 입력받아 달러로 바꾸어 다음 예시와 같이 출력하는 프로그램을 작성하라. 1. $1=1100원으로 가정하고 계산하라. import java.util.Scanner; public class WonToDollar { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("원화를 입력하세요(단위 원)>> "); int won = scanner.nextInt(); System.out.println(won + "원은 $" + (double)(won / 1100) + "입니다."); scanner.close(); } } 2. Scanner 클래스를 .. withTextBook/명품 JAVA 프로그래밍 4년 전