
답안 package prac18; // 손님 이름 및 나이 정보를 위한 Customer 클래스 생성 // 입장료는 1인당 5천원 // 20세 이상에게만 부과 나머진 무료 // 힌트: map()을 이용하여 원하는 형태로 데이터 가공을 할 수 있음. // 삼항연산자 활용 // 메리 50 // 나나 42 // 벤자민 21 // 코코 18 // 마이클 5 // 미술관 입장료 // ----------- // 메리 50 5000원 // 나나 42 5000원 // 벤자민 21 5000원 // 코코 18 무료 // 마이클 5 무료 import java.util.ArrayList; public class Quiz_Prac17 { public static void main(String[] args) { ArrayList ..
public class Practice { public static void main(String[] args) { boolean run = true; int studentNum = 0; int[] scores = null; Scanner sc = new Scanner(System.in); while (run) { System.out.println("--------------------------------------------------------"); System.out.println(" 1. 학생수 | 2. 점수입력 | 3. 점수리스트 |4. 분석 | 5. 종료"); System.out.println("------------------------------------------------------..

풀이 코드 public class quiz { public static void main(String[] args) { Random random = new Random(); // int num = (int) (Math.random() * 100); int num = random.nextInt(100)+1; // 100개의 숫자를 임의로 발생시킨다. Scanner scanner = new Scanner(System.in); int count = 0; // 총 횟수가 필요하므로 초기화 while (true) { // 숫자를 맞출때까지 프로그램을 무한반복한다. 그래서 while을 true로 적었다. System.out.println("숫자를 입력하세요."); // cpu가 생성한 Random숫자 콘솔에서 확인..

풀이 코드 public class quiz { public static void main(String[] args) { Random random = new Random(); int cpu = random.nextInt(3)+1; // System.out.println("CPU: " + cpu); Scanner sc = new Scanner(System.in); System.out.println("가위(1), 바위(2), 보(3): "); int user = sc.nextInt(); if(cpu == 1 && user == 2 || cpu ==2 && user ==3 || cpu ==3 && user ==1) { System.out.println("이겼습니다."); } else if (cpu == user..

풀이 public class Quiz { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] arr = new int[100]; System.out.println("숫자를 입력하세요: "); // 숫자를 100개까지 입력받는 부분 for (int i = 0; i = 0; i--) { if (arr[i] != 0) System.out.print(arr[i..
주요개념 - 클래스, 생성자, 멤버변수, 객체와 인스턴스 Card public class Card { public String user; public int pw; public int bal; public Card(){;} public Card(String user, int pw, int bal) { this.user = user; this.pw = pw; this.bal = bal; } public int getPw() { return pw; } public void setPw(int pw) { this.pw = pw; System.out.println("비밀번호 변경 완료!"); } } 본 클래스 public class Quiz { public static void main(String[] args)..
// 퀴즈1 // 계산기를 구현해 봅니다.(Prac 이 Calc 클래스라고 하고 Prac에 만들어 보기.) // long 타입으로 두 수 를 받아서 덧셈, 뺄셈, 곱셈을 한 값을 반환하는 메소드를 만들고 // 나눗셈의 연산은 double타입으로 반환하는 메서드를 구현합니다. // 메인문에서 사칙연산을 한 값을 인쇄해 보세요. // 메소드명은 자유롭게 지으세요. public class Prac05 { public static long add(long a, long b) { return a + b; } public static long subtract(long a, long b) { return a - b; } public static long multiply(long a, long b) { return a..