본문 바로가기

2022/043

[JAVA] 쉽게 배우는 자바 프로그래밍_5장 문자열, 배열, 열거 타입 본 포스팅은 쉽게 배우는 자바 프로그래밍 교재를 바탕으로 작성되었습니다. Chapter 05. 문자열, 배열, 열거 타입 📍도전 과제 01. 학생 수와 점수를 입력하면 각 학생의 성적을 출력하는 프로그램을 작성해 보자. import java.util.Scanner; public class Do5_1 { public static void main(String[] args) { int numOfStudents = 0; int [] scores; Scanner in = new Scanner(System.in); System.out.print("학생 수 ? "); numOfStudents = in.nextInt(); scores = new int[numOfStudents]; System.out.println(n.. 2022. 4. 25.
[JAVA] 쉽게 배우는 자바 프로그래밍_03장 제어문과 메서드 본 포스팅은 쉽게 배우는 자바 프로그래밍 교재를 바탕으로 작성되었습니다. Chapter 03. 제어문과 메서드 📍도전 과제 01. 키보드로 입력한 정수의 팩토리얼 값을 구하는 프로그램을 작성해 보자. import java.util.Scanner; public class Do_01 { public static void main(String[] args) { int result = 1; int n; Scanner in = new Scanner(System.in); System.out.print("팩토리얼 값을 구한 정수 : "); n = in.nextInt(); /* while ( n > 0) { result *= n; n--; }*/ while (true) { if (n > 0) { result *= n;.. 2022. 4. 24.
[JAVA] 쉽게 배우는 자바 프로그래밍_02장 기초 문법 본 포스팅은 쉽게 배우는 자바 프로그래밍 교재를 바탕으로 작성되었습니다. Chapter 02. 자바 프로그램 구조와 기초 문법 📍도전 과제 01. 직사각형의 가로와 세로를 키보드로 입력받아 넓이를 구하는 프로그램을 작성해 보자. public class Do01 { public static void main(String[] args) { double w, h, area; //직사각형 가로, 세로, 넓이 Scanner in = new Scanner(System.in); System.out.print("직사각형의 가로 길이를 입력하세요 : "); w = in.nextDouble(); System.out.print("직사각형의 세로 길이를 입력하세요 : "); h = in.nextDouble(); System... 2022. 4. 24.