질문있습니다,.
110
동찬 이
작성한 질문수 5
0
package Practice;
import java.util.Scanner;
public class class13 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int maxCount = 10;
String[] productNames = new String[maxCount];
int[] productPrice = new int[maxCount];
int productCount = 0;
while (true) {
System.out.print("1. 상품 등록 | 2. 상품 목록 | 3. 종료\n메뉴룰 선택하세요:");
int menu = scanner.nextInt();
scanner.nextLine();
if (menu == 1) {
if (productCount >= maxCount) {
System.out.println("더 이상 상품을 등록할 수 없습니다.");
continue;
}
System.out.print("상품 이름을 입력하세요:");
productNames[productCount] =scanner.nextLine();
System.out.print("상품 가격을 입력하세요:");
productPrice[productCount] = scanner.nextInt();
productCount++;
} else if (menu == 2) {
if (productCount == 0) {
System.out.println("등록된 상품이 없습니다.");
continue;
}
for (int i = 0; i < productCount; i++) {
System.out.println(productNames[i] + ": " + productPrice[i] + "원");
}
} else if (menu == 3) {
System.out.println("프로그램을 종료합니다");
break;
} else {
System.out.println("잘못된 메뉴를 선택하셨습니다");
}
}
}
}요 코드에서 맨 마지막 else문에 continue; 는 없어도 되나요?
답변 1
IntelliJ IDEA 체험 만료
0
135
2
reference to myMethod is ambiguous 오류
0
102
1
인텔리제이 설정 최신화 관련 확인 부탁 드립니다!
3
283
2
문제와 풀이4 문제점
0
173
2
문제풀이 시간마다 방향성
0
154
2
피라미드 문제 풀이
0
159
1
ScannerWhile3 예제 코드 질문
0
131
1
짝수 출력 문제 질문
0
123
1
Array 연습 문제 5번 질문입니다.
0
166
2
단축어가 이상하게 나옵니다
0
288
2
Sql강의
0
184
1
array 문제풀이 2번 질문입니다.
0
122
1
JAVA입문 / 메서드편 문제와 풀이2
0
135
1
인텔리제이 무료버젼이 통합되었다는데 30일 무료버전이면 어떻게 사용하나요
1
1260
3
OperationEx3에서 꼭 boolean을 써야 하나요?
0
124
1
for, while문 작성
0
135
1
68강 ArrayEx6 클래스 질문
0
123
1
IO.println(String.format("Hello and welcome!"));
0
271
2
소스코드 실행이 안돼요
0
234
2
메서드 문제와 풀이2에서 마지막 문제 이렇게 풀어도 괜찮은 건가요..?
0
118
1
While과 for 스코프 질문
0
110
1
김영한 java 입문 설치 질문
0
218
2
버퍼문제?
0
136
1
for문 피라미드 찍는거 질문
0
123
1





