2017년 11월 10일 금요일

Java 배열 LAB) 극장 예약 시스템

import java.util.Scanner;

// LAB) 극장 예약 시스템
public class Test001 {

public static void main(String[] args) {
final int SIZE = 10;
int i, s;
int seats[] = new int[SIZE];
int cnt=0;

while (true) {
System.out.println("====================");

for(i=0; i<SIZE; i++)
System.out.printf("%d ", i+1);

System.out.println("\n====================");

for(i=0; i<SIZE; i++)
System.out.printf("%d ", seats[i]);

System.out.println("\n====================");
System.out.print("원하시는 좌석번호를 입력하세요 (종료는 -1, 자리가 꽉차면 자동 종료): ");
Scanner sc = new Scanner(System.in);
s = sc.nextInt();

if (s == -1)
break;

if (seats[s-1] == 0) {
seats[s-1] = 1;
System.out.println("예약되었습니다.");
}
else
System.out.println("이미 예약된 자리입니다.");

for (i=0; i<SIZE; i++)
cnt += seats[i];

if (cnt == SIZE)
break;

cnt = 0;

}

}

}

댓글 없음:

댓글 쓰기

시스템 보안

1. 내컴퓨터는 해킹이 당한적 있는가? 있다. 2. 컴퓨터를 하게되면 해킹을 당한다. 무엇을 이용해 해킹을 하는가? 인터넷이 가장 보편적. 사회적인 공격(주변인이 사전정보를 가지고 해킹) 3. 대응을 어떻게 해야하나? 보안프로...