본문 바로가기

<Main>200

자바(JAVA) - 학생 성적 객체화 프로그래밍 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import java.util.Scanner; public class Student { Scanner sc = new Scanner(System.in); String name; //학생이름 int ban; //반 int no; //번호 int kor; //국어점수 int eng; //영어점수 int math; //수학점수 int getTotal() { return kor + eng + math;} float getAverage() { return (((getTotal()*100/3+5)/10)/10f); } } Colored by Color Scripter cs 1 2 3 4 5 6 7 8 9 10 11 12.. 2021. 1. 26.
자바(JAVA) - Sorting method의 객체화 프로그래밍 Sort클래스 멤버변수와 호출 123456789101112131415161718192021222324package main; import sort.Sort; public class MainClass { public static void main(String[] args) { int number[]; boolean updown; Sort sort = new Sort(); sort.userInput(); sort.sorting(); // sort.swap(i, j); int number[] = null; // 1. 숫자 몇개를 정렬? System.out.print("숫자의 갯수 = "); int count = sc.nextInt(); number = new int[count]; // 2. 숫자 갯수에 맞도록.. 2021. 1. 26.
JAVA(자바) - 절차지향과 객체지향 프로그래밍 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 /* 약자 Object Oriented Programming (객체 지향 프로그래밍) class 클래스명 { 변수의 선언 메소드 선언 } */ /* 주사위 게임 number ->2 random ->2 주사위 ->2 numbe.. 2021. 1. 26.
JAVA(자바) - 대표적인 String 메소드, / charAt( intdex); , contains( ); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 //index 숫자를 입력하면 문자 돌려 주는 // charAt String str12 = "가나다라마"; char c = str12.charAt(1); System.out.println("str12 = " + c); //나 출력 //문자열 탐색 // contains String str13 = "서울시 마포구 서교동"; boolean b1 = str13.contains("마포"); System.out.println("str13 = " + b1 ); // true 출력 cs .charAt( intdex); index 숫자를 입력하면 문자를 돌려준다. .contains( "찾고자하는 문자열" ); 문자열을 탐색해준다. - > 탐색하여 있는지 없는지 .. 2021. 1. 25.