수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

자바 배열 저장후 출력 질문이요

텃골돌샘터

2023.04.01

지금 입력까지는 되는데 (2)상품조회 하는부분을 못하구있어요
입력받은걸 저장했다가 출력하는 방법을 잘모르겠어요...
소스 수정부탁드립니다
배열이 아니라도 입력받은걸 조회해서 출력 할 수있게 해주세요
import java.util.Scanner;
class Product {
String proID;
String desc; //상품설명
String maker; //생상자
int price; //가격
void proinfo(){

Scanner scan = new Scanner(System.in);
System.out.printf(상품ID);
proID=scan.nextLine();

System.out.printf(상품설명);
desc=scan.nextLine();

System.out.print(생산자);
maker = scan.nextLine();

System.out.print(가격);
int price = scan.nextInt();

scan.nextLine();

}
void proshow() {
System.out.println(상품D+proID);
System.out.println(상품설명+desc);
System.out.println(생산자+maker);
System.out.println(가격+price);

}
}

class Book extends Product {

String ISBN; //ISBN
String title; //책제목
String author; //저자
void bookinfo() {
Scanner scan = new Scanner(System.in);
proinfo();
System.out.print(ISBN);
ISBN = scan.nextLine();
System.out.print(책제목);
title = scan.nextLine();
System.out.print(저자);
author= scan.nextLine();
}

void bookshow() {
proshow();
System.out.println(ISBN+ISBN);
System.out.println(책제목+title);
System.out.println(저자+author);
}
}
class ConversationBook extends Book{
String language;
void coninfo(){
Scanner scan = new Scanner(System.in);
super.bookinfo();
System.out.print(언어);
language = scan.nextLine();
}

void conshow() {
super.bookshow();
System.out.println(언어+language);
}
}

class CompactDisc extends Product {
String albumtitle; //앨범제목
String artist; //가수
void albuminfo(){
Scanner scan = new Scanner(System.in);
proinfo();
System.out.print(앨범제목);
albumtitle=scan.nextLine();
System.out.print(가수);
artist=scan.nextLine();
}

void albumshow() {
proshow();
System.out.println(앨법제목+albumtitle);
System.out.println(가수+artist);
}

}
public class y{
public static void main(String[] args) {
int proID = 0;
int numberOfProduct = 0;
Product[] p = new Product[10];Book book = new Book();
ConversationBook con = new ConversationBook();
CompactDisc com = new CompactDisc();Scanner scan = new Scanner(System.in);
int choice=0;
int type;
while(choice != 3) {
System.out.print(상품추가(1), 모든상품조회(2), 끝내기(3));
choice = scan.nextInt();
switch (choice) {
case 1: //상품추가
System.out.print(상품종류책(1), 음악D(2), 회화책(3));
type = scan.nextInt();
switch(type) {
case 1:
book.bookinfo();
break;
case 2:
com.albuminfo();
break;
case 3:
con.coninfo();
break;
}
break;
case 2: //모든상품조회
{
book.bookshow();
com.albumshow();
con.conshow();
}
break;
case 3: //끝내기
break;
}
}
}
}

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2701397 세로 100% 푸터부분이 바닥에 안붙어요(세로 100% 되는 소스를 썼거든요) 꽃겨울 2025-07-13
2701369 [긴급]로드해온 swf가 갑자기 사라지는 현상..(익스10) (2) 곰돌이 2025-07-13
2701340 [c++]학교 과제 질문이요...... (3) 기쁨해 2025-07-13
2701311 구글 뉴스검색최적화 작업은 누구의 영역인가요? 많은 조언 부탁드려요! 리나 2025-07-13
2701285 아이폰이나 안드로이드 폰 인터넷으로 볼때 배꽃 2025-07-12
2701230 테마 설정하면 밑에 뜨는 글 삭제 (1) 창의적 2025-07-12
2701177 css적용이 안되요~ (6) 다니엘 2025-07-11
2701151 사이트작업시 inputbox 가 readonly 형태표시 어떻게 하시나요? (1) 찬내 2025-07-11
2701123 간단한 select 질문입니다 (3) 천사의눈물 2025-07-11
2701061 비베질문.. 똘끼 2025-07-10
2701034 메일폼 내 script 삽입가능한 방법 없을까요.. (2) 마음새 2025-07-10
2701008 분명히 버튼을 만들었는데 액션이 안걸립니다. (3) 재찬 2025-07-10
2700923 전체중앙정렬&독타입&쿼크모드 ㅜㅠ (8) 푸른들 2025-07-09
2700893 질문드리겠습니다. 도도한 2025-07-09
2700793 무비클립에 마우스 오버시 랜덤으로 효과음 나기는 어떻게 ;; (1) 바닐라 2025-07-08
2700741 웹전송? (2) 연와인 2025-07-07
2700686 카테고리 호버시 세부카테고리 보이게하는 것, css로만 가능할까요?? (3) 다힘 2025-07-07
2700658 메타태그 질문드립니다..ㅠㅠ;;; 모해 2025-07-07
2700632 외부에서 이미지 파일을 불러와야 합니다. 도와주세요. (4) 에일린 2025-07-06
2700579 (air + as3) smtp 이용해서 첨부파일 포함해서 메일 보내기 물보라 2025-07-06
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com