-
비행기 정보 출력(입력 없음)코딩/java 2018. 11. 27. 14:36반응형
public class Plane {
String model;
int id, capacity;
}
-------------------------------------------------------------------------------
public class Practice_38 {
public static void main(String[] args) {
Plane def = new Plane();
Plane jeju = new Plane();
Plane seoul = new Plane();
//def.id = 0;
def.model = "모름";
//def.capacity = 0;
jeju.id = 1030615;
jeju.model = "보잉 737";
jeju.capacity = 75;
seoul.id = 2464737;
seoul.model = "보잉 747";
seoul.capacity = 150;
System.out.println("디폴트 비행기의 정보입니다.");
System.out.println("식별번호: " + def.id + "편");
System.out.println("모델: " + def.model);
System.out.println("승객수: " + def.capacity + "명");
System.out.println("제주행 비행기의 정보입니다.");
System.out.println("식별번호: " + jeju.id + "편");
System.out.println("모델: " + jeju.model);
System.out.println("승객수: " + jeju.capacity + "명");
System.out.println("서울행 비행기의 정보입니다.");
System.out.println("식별번호: " + seoul.id + "편");
System.out.println("모델: " + seoul.model);
System.out.println("승객수: " + seoul.capacity + "명");
}
}
결과:
반응형'코딩 > java' 카테고리의 다른 글
생일, 성년일(Class) (0) 2019.01.02 나이가 중간인 사람 계산 (0) 2019.01.02 영화 평점, 개봉 년도 비교 (0) 2018.11.27 은행 계좌(입력 없음) (0) 2018.11.27 2개의 사각형의 넓이, 둘레 계산 (0) 2018.11.27