๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

Java107

[Java-๊ธฐ์ดˆ] ์‹ค์Šต (ํ•ฉ๊ณ„, ํ‰๊ท , ์„์ฐจ ์‚ฐ์ถœ ํ”„๋กœ๊ทธ๋žจ) Subject.java package subject; public class Subject { protected int kor, eng, math, sum; protected double avg; public int getKor() { return kor; } public void setKor(int kor) { this.kor = kor; } public int getEng() { return eng; } public void setEng(int eng) { this.eng = eng; } public int getMath() { return math; } public void setMath(int math) { this.math = math; } public int getSum() { return s.. 2021. 2. 24.
[Java-๊ธฐ์ดˆ] ์‹ค์Šต (์ฃผ๋ฌธ๋ฒˆํ˜ธ, ์ƒํ’ˆ์ด๋ฆ„, ์ƒํ’ˆ๊ฐ€๊ฒฉ, ๊ฐฏ์ˆ˜) package quiz; public class OrderData { private int orderNum; private String orderProduct; private int price; private int qty; private MemberData memberData; public OrderData() { } public OrderData(int orderNum, String orderProduct, int price, int qty, MemberData memberdata) { this.orderNum = orderNum; this.orderProduct = orderProduct; this.price = price; this.qty = qty; this.memberData = memberd.. 2021. 2. 24.
[Java-๊ธฐ์ดˆ] ์‹ค์Šต (๋ฉค๋ฒ„ ํ˜ธ์ถœ) ์‹ค์Šต) get,set ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ฐ‘์— ๋‚ด์šฉ์ฒ˜๋Ÿผ ์ถœ๋ ฅ๋˜๊ฒŒ ํ•˜์‹œ์˜ค ์กฐ๊ฑด : ๋ฉ”์„œ๋“œ ์žฌ์ •์˜, ArrayList ์‚ฌ์šฉํ•ด์„œ ํšŒ์› ์ž…๋ ฅ โ€‹ โ€‹ MemberData.java package quiz; public class MemberData { private String memberID; private String name; private String tel; private String gender; public MemberData(String memberID, String name, String tel, String gender) { this.memberID = memberID; this.name = name; this.tel = tel; this.gender = gender; } public MemberD.. 2021. 2. 24.
[Java-๊ธฐ์ดˆ] ์‹ค์Šต (๋ฉ”์„œ๋“œ๋กœ ๊ตฌ๊ตฌ๋‹จ ํ˜ธ์ถœํ•˜๊ธฐ) ์‹ค์Šต) ๊ตฌ๊ตฌ๋‹จ์„ ๋งŒ๋“ค์–ด๋ณด์‹œ์˜ค. ์กฐ๊ฑด : ๋ฉ”์„œ๋“œ๋กœ ํ˜ธ์ถœํ•˜๊ธฐ โ€‹ โ€‹ ProgTest1.java package quiz; import java.util.Scanner; public class ProgTest1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("๋ช‡๋‹จ์„ ๋ณด์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?"); int n = sc.nextInt(); int dan, times; System.out.println(n + "๋‹จ :"); for (dan = n; dan 2021. 2. 24.
[Java-๊ธฐ์ดˆ] ์‹ค์Šต (๋กœ๋˜ ์ถ”์ฒจ ๋ฒˆํ˜ธ) ์‹ค์Šต ) ๋กœ๋˜ ๋ฒˆํ˜ธ๋ฅผ ๋žœ๋ค์œผ๋กœ ์ถ”์ฒจํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์กฐ๊ฑด : nextInt( ) ๋ฉ”์„œ๋“œ ์‚ฌ์šฉํ•˜๊ธฐ โ€‹ โ€‹ 1. ์‚ฌ์‹ค ๋กœ๋˜๋ฅผ ์•ˆํ•ด๋ด์„œ ์ž˜ ๋ชฐ๋ž๋‹ค. ์ˆซ์ž๊ฐ€ 45๋ฒˆ๊นŒ์ง€ ์žˆ๋Š”๊ฒƒ๋„;; Random ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑํ•˜๊ณ  nextInt( ) ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค๋Š” ํžŒํŠธ๋ฅผ ๋ฐ›์•˜๋‹ค. โ€‹ โ€‹ RandomLotto.java package lotto; import java.util.Random; public class RandomLotto { public static void main(String[] args) { int[] lotto = new int[7]; // ๋กœ๋˜๋ฒˆํ˜ธ 7๊ฐœ int cnt = 0; // ์ˆซ์ž ์ƒ์„ฑ Random rm = new Random(); System.out.print("๋กœ๋˜๋ฒˆํ˜ธ ์ƒ์„ฑ : ");.. 2021. 2. 24.
[Java-๊ธฐ์ดˆ] ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์‹ค์Šต (๋งˆ๋ฐฉ์ง„) *๋งˆ๋ฐฉ์ง„์ด๋ž€ ? ๋งˆ๋ฐฉ์ง„์€ ‘1๋ถ€ํ„ฐ n์ œ๊ณฑ’๊นŒ์ง€์˜ ์—ฐ์†๋œ ์ž์—ฐ์ˆ˜๋ฅผ ๊ฐ€๋กœ, ์„ธ๋กœ, ๋Œ€๊ฐ์„ ์˜ ํ•ฉ์ด ๊ฐ™์•„์ง€๋„๋ก ์ •์‚ฌ๊ฐํ˜• ๋ชจ์–‘์œผ๋กœ ๋ฐฐ์—ดํ•œ ๊ฒƒ. โ€‹ โ€‹ ์‹ค์Šต ) ๋ฐ‘์˜ ๊ฒฐ๊ณผ์™€ ๊ฐ™์ด ๋‚˜์˜ค๊ฒŒ ๋งŒ๋“œ์‹œ์˜ค. ์กฐ๊ฑด : ๋ฒ„ํผ๋ฆฌ๋”, ๋งˆ๋ฐฉ์ง„ โ€‹ โ€‹ ์™„์„ฑ๋ชปํ•จ.. โ€‹ 1. ์ˆœ์„œ๋„ ๋ณด๋ฉด์„œ ํ• ๋ผ๋‹ˆ๊นŒ ๋ปํ‚นํ–ˆ๋‹ค. (์ˆœ์„œ๋„ ๋ณด๋Š”๋ฒ• ์•ˆ๊ฐ€๋ฅด์ณ์คŒ) ๊ทธ๋ž˜๋„ ์„ ์ƒ๋‹˜๊ป˜์„œ ์น ํŒ์—๋‹ค ๋Œ€์ถฉ ์–ด๋–ค ์‹์œผ๋กœ ํ•ด์•ผํ•˜๋Š”์ง€ ํฐ ํ‹€์„ ์ ์–ด์ฃผ์‹ฌ. int N = 0; // ๋ฐฐ์—ด ๊ฐ’ int k = 0; // ๋งˆ๋ฐฉ์ง„ ์•ˆ์— ๋“ค์–ด๊ฐˆ ์ˆซ์ž int[][] arr = new int[N][N]; // ๋ฐฐ์—ด int i = 1; // ํ–‰ int j = (N / 2) + 1; // ์—ด // ๋ฐฐ์—ด ์ž…๋ ฅ ๋ถ€๋ถ„ System.out.println("๋งˆ๋ฐฉ์ง„์„ ๊ตฌํ•  ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” : "); N .. 2021. 2. 24.
๋ฐ˜์‘ํ˜•