Java/쉽게 배우는 자바 프로그래밍 [2판]7 [쉽게 배우는 자바 프로그래밍 2판] 5장 프로그래밍 문제 1~5번 01 public class Chap5 { public static void main(String[] args) { String s = "abcadapvad"; System.out.println(countChar(s, 'a')); } static int countChar(String s, char c) { int num=0; for(int i=0;i 2023. 2. 26. [쉽게 배우는 자바 프로그래밍 2판] 4장 프로그래밍 문제 5~8번 05 class Line{ private int line; public Line(int line){ this.line = line; } public int getLine() { return line; } public boolean isSameLine(Line l) { return line == l.getLine(); } } public class Chap4{ public static void main(String[] args) { Line a = new Line(1); Line b = new Line(1); System.out.println(a.isSameLine(b)); System.out.println(a==b); } } 06 class Complex{ private double real, ima; .. 2023. 2. 26. [쉽게 배우는 자바 프로그래밍 2판] 4장 프로그래밍 문제 1~4번 01 class Triangle{ private double bottom, height; public Triangle(double bottom, double height) { this.bottom = bottom; this.height = height; } public void getinfor() { System.out.println("밑변 : " + bottom); System.out.println("높이 : " + height); } public double findArea() { return bottom*height/2; } } public class Chap4{ public static void main(String[] args) { Triangle t = new Triangle(10.0, 5.0.. 2023. 2. 26. [쉽게 배우는 자바 프로그래밍 2판] 3장 프로그래밍 문제 6~10번 06 import java.util.Scanner; public class Chap3{ public static void main(String[] args) { Scanner in = new Scanner(System.in); String Chul, Young; System.out.println("r, s, p 중 하나를 입력하세요(소문자로)"); System.out.print("철수 : "); Chul = in.next(); while(!Chul.equals("r") && !Chul.equals("s") && !Chul.equals("p")) { System.out.print("다시 입력 : "); // 올바르게 입력하지 않은 경우 while문 실행 Chul = in.next(); } System.ou.. 2023. 2. 25. [쉽게 배우는 자바 프로그래밍 2판] 3장 프로그래밍 문제 1~5번 public class Chap3 { public static void main(String[] args) { int ans = 0; for(int a=1;a 2023. 2. 25. [쉽게 배우는 자바 프로그래밍 2판] 2장 프로그래밍 문제 6~10번 06 public class Chap2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("화씨 온도를 입력하시오 : "); double F = in.nextDouble(); System.out.println("화씨 온도 : " + F + " 섭씨 온도 : " + (double)(5/9*(F-32))); } } 07 public class Chap2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("정수를 입력하세요 : "); int x = in.nextInt.. 2023. 2. 24. [쉽게 배우는 자바 프로그래밍 2판] 2장 프로그래밍 문제 1~5번 01 public class Chap2 { public static void main(String[] args) { System.out.println( " *"); System.out.println( " ***"); System.out.println( " *****"); System.out.println( " *******"); System.out.println( " *********"); System.out.println( "***********"); } } 02 import java.util.Scanner; public class Chap2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.. 2023. 2. 24. 이전 1 다음