import javax.swing.JOptionPane;
public class market4 {
public static void main(String[] args) {
System.out.println("---MENU---");
String[] menu = {"[1]item list","[2]sales","[3]print","[4]exit"};
for (int i=0;i<4;i++) {
System.out.println(menu[i]);
}
int MenuList;
String MenuString = JOptionPane.showInputDialog(null, " Choose number: ");
MenuList = Integer.parseInt(MenuString);
if(MenuList==1) {
System.out.println();
String[] list = {"hotdog","donut","eggpie","pizza","lasagna"};
int[] cost = {5,15,25,35,45};
int[] selling = {10,20,30,40,50};
int[] qty ={5,5,5,5,5};
System.out.println("item"+"\tcost"+"\tSelling"+"\tinv qty");
for (int m=0; m<list.length;m++) {
System.out.println(list[m]+"\t"+cost[m]+"\t\t"+selling[m]+"\t\t"+qty[m]);
}
for (int i = 0; i < 5; i++) {
String input = (String) JOptionPane.showInputDialog(null,
"Select an Item", "Welcome " + "!",
JOptionPane.QUESTION_MESSAGE, null, list, "Hotdog");
String[] itemQuantity = { "1", "2", "3", "4", "5" };
String itemq = (String) JOptionPane.showInputDialog(null,
"Enter Quantity", "Welcome",
JOptionPane.QUESTION_MESSAGE, null, itemQuantity, "1");
}
} else if(MenuList==2) {
JOptionPane.showMessageDialog(null,"sales");
} else if(MenuList==3) {
JOptionPane.showMessageDialog(null,"print");
} else if(MenuList==4) {
JOptionPane.showMessageDialog(null,"Exit,Bye");
} else {
System.out.print("Invalid");
}
}
}
방금 첫 배열 프로그램을 만들었습니다.어레이 시장은 가이드 나 대답이 필요합니다.
JOptionPane.showMessageDialog(null,"print");
내가 메뉴를 요구하고있다 :
이JOptionPane.showMessageDialog(null,"sales");
는 또한 인쇄 섹션에서 내가 구입 한 항목에 대한 인쇄를 확인하기 위해 프로그램이 필요 : 여기 내 입력을 얼마나 모르겠어요 반복 할 수 있습니다. menulist == 1 menulist == 2에 인쇄 할 수 있습니다. 그게 다예요 :) < 이미 완료
정확하게 무엇이 문제입니까? 컴파일 오류, 예외, 논리적 인 문제, ... –
아무것도 입력을 얻는 방법을 모르겠다 그래서 항목과 그것의 가격을 볼 수 있도록 – bhw
JOption의 String [] 목록 옵션을 원한다고 말하고 있습니까? 창유리? 또는 항목, 이름, 가격을 표시하고 싶습니다. e.t.c – Levenal