-1
내 프로그램은 누군가에게 제품의 일련 번호와 가격을 입력하도록 요청합니다. 여기 루프가 첫 번째 반복 이후 첫 번째 입력 스캐너를 건너 뛰는 동안?
이 출력Enter the item number or enter 0 when you are done.
input
Enter the original price or enter 0 when you are done.
input
그러나 완벽하게 처음 작업을 한 후 클래스 드라이버
import java.io.*;
import java.util.Scanner;
public class InventoryDriver {
public static void main(String[] args)throws IOException {
Inventory storeItem = new Inventory(" ", 1);
PrintWriter storeFile = new PrintWriter("StoreInventory.txt");
Scanner scan = new Scanner(System.in);
boolean running = true;
String itemNum = " ";
double originalPrice = 1;
while (running) {
System.out.println("Enter the item number or enter 0 when you are done.");
itemNum = scan.nextLine();
storeItem.setItemNum(itemNum);
storeFile.println(itemNum);
if(itemNum.equals("0")) break;
System.out.println("Enter the original price or enter 0 when you are done.");
originalPrice = scan.nextDouble();
storeItem.setOriginalPrice(originalPrice);
storeFile.println(originalPrice);
if(originalPrice == 0) break;
}
//create a scanner variable named myFile
Scanner myFile = new Scanner(new File("StoreInventory.txt"));
//Read my data from my file into the variablles
//itemNum = myFile.nextLine();
//originalPrice = myFile.nextDouble();
printSaleData(myFile, storeItem);
//Close the file
myFile.close();
storeFile.close();
}
}
입니다 루프가 다시 갈 때,이
Enter the item number or enter 0 when you are done.
input
Enter the original price or enter 0 when you are done.
input
Enter the item number or enter 0 when you are done.
Enter the original price or enter 0 when you are done.
input
을 인쇄 무엇 내 코드가 첫 번째 이동 후 루프를 변경합니까?
P. 루프를 깨뜨린 후에도 전체 프로그램이 멈추고 "printSaleData"하위 모듈을 주 모듈에 호출하지 않습니다.
이러한 결과를 얻기 위해 입력 한 내용을 정확히 명확하게 설명해 주시겠습니까? 찾고있는 산출물은 정확히 무엇입니까? – Keara
아마도'itemNum = scan.nextLnt();'를'itemNum = scan.nextInt();'로 바꿀 것입니다. – icarumbas