Question: public class VehicleApp { private static final DecimalFormat df 2 = new DecimalFormat ( # . ## ) ; / * * *

public class VehicleApp {
private static final DecimalFormat df2= new DecimalFormat("#.##");
/**
* @param args the command line arguments
*/
public static void main(String[] args){
// TODO code application logic here
String FName="",LName="",phoneNumber=""; //Variable Declaration
int numOfVehicles=0,numOfTanks=0;
//First name must be asked until is it blank
while(FName.isEmpty()){
FName=JOptionPane.showInputDialog("Enter first name");
}
//Last Name must be asked until is it blank
while(LName.isEmpty()){
LName=JOptionPane.showInputDialog("Enter Last Name");
}
//Phone number must be asked 10 characters and can not be blank
while (phoneNumber.length()!=10||!phoneNumber.matches("\\d+")){
phoneNumber=JOptionPane.showInputDialog("Enter Phone Number(10 Digits)");
}
// Number of Vehicles must be between1 and 10
while(numOfVehicles1||numOfVehicles>10){
try{
String vehicles = JOptionPane.showInputDialog("Enter number of vehicles (1-10)");
numOfVehicles=Integer.parseInt(vehicles);
} catch (NumberFormatException e){
JOptionPane.showMessageDialog(null,"Please enter a valid number");
}
// Number of Tanks must be one of the specified values
try {
while (!(numOfTanks ==2|| numOfTanks ==4|| numOfTanks ==8|| numOfTanks ==10|| numOfTanks ==15|| numOfTanks ==20)){
String tanks = JOptionPane.showInputDialog("Enter number of tanks (2,4,8,10,15,20)");
numOfTanks = Integer.parseInt(tanks);
}
} catch (NumberFormatException e){
JOptionPane.showMessageDialog(null, "Please enter a valid number");
}
// Create VehicleFactory instance and display summary
VehicleFactory VF = new VehicleFactory(FName +""+ LName, phoneNumber, numOfVehicles, numOfTanks);
JOptionPane.showMessageDialog(null, VF.getSummary());
}
public class VehicleApp { private static final

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!