(Solved) : Please Help Problems Validation Java Switch Case Allowing Add Another Vehicle Displayed Ve Q37167335 . . .

Please help. I am having problems with validation in Java and myswitch/case is not allowing me to add another vehicle after I havedisplayed a vehicle. Cannot use scanner…

Items needed to validate:

WE WRITE PAPERS FOR STUDENTS

Tell us about your assignment and we will find the best writer for your project

Write My Essay For Me

–Vehicle VIN: exactly 10 characters (a combination of lettersand digits)

–Vehicle Make: all alphabetic

–Vehicle Model: letters and digits

Here is what I have so far:

<img alt=”//lets declare an array list to store all vehicles static ArrayList<car» carList = new ArrayList<carx(); static ArrayList

//let’s declare an array list to store all vehicles static ArrayList<car» carList = new ArrayList<carx(); static ArrayList boatList = new ArrayList(); //working variables static int carCount- 0; static int boatCount-0; static String getsearchVIN” static boolean valid – false; public static void main(String[] args) int menu○ption = 0; int addoption0; int dispOption0; int foundAt-1; while(menuoption3) me nuoption menu(); = switch(menuoption) case 1: while(addOption – 3) addOptionaddVehicleMenu); switch(addOption) case 1: car carVehnew car); carVeh.getVehicle(); carVeh.getCar(); carList.add(carVeh); carcount++; break; case 2: boat boatVeh- new boat) boatVeh.getVehicle(); boatVeh.getBoat(); boatList.add (boatVeh); boatCount++; break; 446 47 48 49 50 /end switch addoption )//end while addoption break; while(dispoption 2: != 3) case dispOption- dispMenu); switch(dispoption) 53 54 case 1: getVIN): 56 57 58 59 60 61 62 foundAt searchCarVIN(); if(foundAt < 0) JOptionPane. showlessageDialog(null, “VIN not found!”); else for(int i -0; i < carCount; i++) carlist.get(foundAt).dispVehicle); carList.get(foundAt).dispCar); 64 65 break; case 2: getVIN) 67 68 69 70 71 72 73 74 75 76 foundAt = searchBoatVIN(); if(foundAt <0) OptionPane. showrlessageDialog(null, “VIN not found!”); else for(int i = 0; i < boatCount; 1++) boatList.get (foundAt).dispVehicle); boatList.get (foundAt).dispBoat); break; 78 79 80 // end dispoption //end while dispOption break; 83 84 85 86 87 case 3: 30ptionPane. showlessageDialog(null, “Thank you for using the program!”); break; default: JOptionPane.showlessageDialog(null, “Wrong selection!”); )//end switch menuOption 89 90 91 //end main /end while menuOption 93e 94 95 96 public static int menu() string input “”; int menuOption0; input- JOptionPane.showInputDialog(“-1-Add Vehiclen” “-2-Display Vehicleln” “-3-Quit programn” “In n tEnter a selection 1-3:”); 98 100 101 102 103 104 105 11 106e menuOption = Integer.parseInt(input); return menuOption; /end menu public static int addVehicleMenu() 107 108 109 110 string input = “”; int addOption- 0; input = JOptionPane . showinputDialog(“-1-Add Carin” “-2-Add Boatn” “-3-Go Back to Main Menun”+ “in nltEnter a selection 1-3:”); 112 113 114 addoption integer.parseInt(input); return addoption; 115 116 //end addVehicleMenu public static int dispMenu() 119Θ 120 121 122 123 124 125 126 string input “”; int dispoption = 0; input = JOptionPane. showinputDialog(“-1-Display Carin” “-2-Display Boatn” “-3-Go Back to Main Menun”+ “nntEnter a selection 1-3: “) dispoption = Integer.parseInt(input); return dispOption; 127 128 129 public static void getVIN) boolean valid = false; String input – input-JOptionPane.showInputDialog(“Enter the VIN Number: “); validvalidateVIN (input); while(!valid) input- JOptionPane.showInputDialog(“Invalid VIN Number…please re-enter VIN number: “) valid = validateVIn( input); getsearchVIN -input; //end getVIN public static int searchCarVINO for(int i 0; i < carcount; i++) if(getsearchVIN.equals (carList.get(i).VIN)) return i; /end for i return -1; //end searchcarVIN public static int searchBoatVIN) for(int i -0; i < boatCount; i++) if(getsearchVIN. equals (boatList.get(i).VIN)) return i; //end for i return -1; /end searchBoatVIN public static boolean validatevIN(String input) boolean valid – false; if(input.length10) 68 69 70 71 72 73 74 75 76 for(int i 0; i input . length(); i++) < if( ! Character. ISDigit(input. charAt(1))) return false; )//end for for(int i -0; i < input.length(); i++) if( ! Character. ISALphabetic(input. charAt(1))) 78 79 80 81 82 83 84 return false; //end for return true; return false; )//end validateVIN 85 //end class pp1_small 86 / 87 class vehicle //attributes: String VIN; String make; String model; //constructors: vehicle() //this is also a super fons太w/o arguments called from the subclasses 89 90 91 92 93 95 96 make “”, model = “”; 98 /end const w/o arguments …default vehicle(String VIN, String make, String model) //this is also a super 01 02 03 04 05 this.VINVIN; this.make make this.mode! = model; /end const w/ arguments class vehicle 87 //attributes: String VIN; String make; String model; //constructors: vehicle() //this is also a super fona太w/o arguments called from the subclasses 89 90 91 92 93 946 95 96 97 98 VIN”” make “”. model = “”; )//endSRDS太w/o arguments default vehicle(String VIN, String make, String model) //this is also a super 00e 01 02 03 04 05 this.VINVIN this.makemake; this.modelmodel; /end const w arguments void getVehicle() 08 boolean valid-false; String input”; input-JOptionPane.showInputDialog(“Enter VIN: “) valid-validateVIN (input); while(!valid ) 09 10 12 13 14 input = JOptionPane . ShowinputDialog(null, “Invalid valid-validateVIN(input); VIN Number please VIN Number: “); re-enter 16 17 VIN input; input = JOptionPane. ShowinputDialog(“Enter Vehicle Make: “); make-input; input-JOptionPane.showInputDialog(“Enter Vehicle Model: “); model- input; 18 19 20 //end getPatient 23 24 11- 25e 226 void dispVehicle) OptionPane. showlessageDialog(null, “Vehicle VIN:VIN “n” + “make “”+ ” Vehicle Make: “Vehicle Model: ” model); 229 230 /end dispVehicle public static boolean validateVIN(String input) 32e 233 234 235 36 37 238 239 240 if(input.length)10) for(int i – 0; i < input.length); i++) if( ! Character. ISDigit(input, charAt(1))) return false //end for for(int i = 0; i < input, length(); i++) 42 43 244 45 246 47 248 49 50 if( ! Character. ISAlphabetic(input, charAt(i))) return false: //end for return true; return false //end validateVIN //end class vehicle 51 II 53 54 class car extends vehicle //class car inherits from class vehicle //attributes: double enginesize; 56 58 59e 60 61 62 63 64 65e //constructors: car() super) engineSize -00.00; //end constructor w/o arguments car(String VIN, String make, String model, double engineSize) 67 68 69 70 71e 72 73 74 75 76 super (VIN, make, model); this.enginesize = enginesize; //end constructor w/arguments void getCar() string input = ” “; input – JOptionPane. showInputDialog(“Enter Engine Size: “); engineSize = Double.parseDouble(input); //end getCar 78 79e 80 81 82 83 84 void dispCar() JOptionPane. showlessageDialog(null, “Car Information:” “Engine Sizae: ” engineSize); //end dispCar //end class Car 286 287 288 289 290 291 292e 293 294 295 296 297 298 299e 300 301 302 303 304 305 306 307e 308 309 310 311 312 313 314 315 316 317e 318 319 320 321 322 323 324 class boat extends vehicle //class Boat inherits from class vehicle //attributes: String boatType; int engineHours; //constructors: boat() super): boatType ; engineHours0; //end constructor w/o arguments boat (String VIN, String make, String model, String boatType, int engineHours) super (VIN, make, model); this.boatType boatType; this.engineHoursengineHours; /end constructor w/arguments //methods: void getBoat() String input” input-JOptionPane.showInputDialog(“Enter Boat Type: “); boatType- input; input-JOptionPane.showInputDialog(“Enter Engine Hours: “); engineHours-Integer.parseInt(input); )//end getoutpatient void dispBoat() JOptionPane. showrlessageDialog(null, “Boat Information: n”+ Boat Type:” boatType + “Engine Hours: “+engineHours); )//end dispBoat //end class Boat Show transcribed image text //let’s declare an array list to store all vehicles static ArrayList

Expert Answer


I lOVE this Professional essay writing website. This is perhaps the fifth time I am placing an order with them, and they have not failed me not once! My previous essays and research papers were of excellent quality, as always. With this essay writing website, you can order essays, coursework, projects, discussion, article critique, case study, term papers, research papers, research proposal, capstone project, reaction paper, movie review, speech/presentation, book report/review, annotated bibliography, and more.

Post your homework questions and get original answers from qualified tutors!

PLACE YOUR ORDER

Share your love