private void enterData() { carRegistration = registrationField.getText(); // car registration is what users type in the registration field carAge = Integer.parseInt((String) ageCombo.getSelectedItem()); // the age is to be selected from the combo box boolean accident = accidentCheckBox.isSelected(); // the accident status depends on whether or not the checkbox is ticked discount = Fee*0.25; // declaring that the discount is 25% of the fee int[] cars; // declare an array called cars cars = new int[ 10 ]; // declare the number of cars if(accidentCheckBox.isSelected()) // if the accident checkbox is displayed, the accident status should display as YES Accident = "YES"; else Accident = "NO"; // if the accident checkbox is displayed, the accident status would display as NO if(carAge>5) Fee = 350.00; // if the car is above 5 years of age, the fee would be $350.00 if(carAge<=5) Fee = 200.00; // if the car is under or equal to 5 years of age, the fee would be $200.00 if(accidentCheckBox.isSelected()) Fee = Fee; // if the car has been in an accident, the fee will not change else Fee = Fee - discount; // if the car has not been in an accident, the fee will be discounted if(registrationField.getText().equals("")) { JOptionPane.showMessageDialog(this, "Please enter a car's registration"); // error message if car registration isn't entered } else { textArea.setText(String.format("%10s %10s %10s %10s", "Registration","Age", "Accident", "Fee\n")); // placing the titles of the four categories of information into text textArea.append(String.format("--------------------------------------------\n")); // underline separates the titles of categories from the information of each car textArea.append(String.format("%10s %10s %10s %10s", carRegistration, carAge, Accident, "$" +Fee)); // the four categories information displayed into text for each car } registrationField.setText(""); // reset the registration field when data is entered ageCombo.setSelectedIndex(0); // reset the combo box to the default number selected when data is entered accidentCheckBox.setSelected(false); // reset the check box to its default state when data is entered registrationField.requestFocus();
I just want to loop the Registration, Age, Accident and Fee displayed for a car 10 times.