尝试将信息从JOptionPane存储到数组中,但数组保持循环

时间:2016-04-26 15:26:01

标签: java arrays arraylist joptionpane

我正在编写一个程序,主要是使用JOptionPane从JOptionPane中输入的信息中存储数组中的5只狗,但信息不会进入数组并且程序会循环

import javax.swing. JOptionPane;
import java.util.Scanner;
import java.io.IOException;
import java.util.*;

public class DogKennelGui2 {

    public static void main(String[] args) 
        double[] dogStaying = new double [5]; // Stores dog breeds  
        String dogBreed, daysHeld; 
        double price1 = 25; 
        double price2 = 50; 
        double price3 = 75; 
        final double SALES_TAX =.07;  
        final double FED_TAX = .14; 
        JOptionPane.showMessageDialog(null,
                    "WELCOME TO METROPOLITAN DOG KENNEL",
                        "METROPOLITAN DOG KENNEL",
                        JOptionPane.INFORMATION_MESSAGE); 
        int i=0;
        while(i<5) {
            try{
                dogStaying[i] = Double.parseDouble (
                        JOptionPane.showInputDialog(
                        "Enter the breed of dogs you" + 
                        " will be leaving with us today:"));
                i++;
            } catch(Exception e) {
                JOptionPane.showMessageDialog ( null,
                    "The max number of dogs per customer is five:");
            }
        }
    }
}
// Why does it continue looping? 

0 个答案:

没有答案