outprintln carsFound if carsFound 0 SystemoutprintlnNo cars found

Outprintln carsfound if carsfound 0

This preview shows page 2 - 5 out of 8 pages.

System.out.println(""); carsFound++; } } if (carsFound ==0) { System.out.println("No cars found"); System.out.println(""); } } /** * Searches for all the cars that are between a desired minimum value and a maximum value * @param minimum The minimum determined. * @param maximum The maximum determined. */
Image of page 2
public static void findCarsWithinPriceRange(Car[] carDatabase, int min, int max) { for(int i=0;carDatabase[i]!=null; i++) { if(carDatabase[i].price>=min && carDatabase[i].price<=max) System.out.println(carDatabase[i]); System.out.println("");; } } // PART 2 // this part of the main method that runs the program. // there is a total of 5 options that the user can choose from. // the first two options require a password which we set as a constant // two static methods for options 3 and 4 are created. public static void main(String[] args) { // declare variables Scanner kb = new Scanner(System.in); int carUserInput = 0; final String PASSWORD = "comp249S19"; String make; String model; int year; int price; String userPassword; int counter=0; //keep track of number of times password is entered int totalAttempts=0; int remainingCars; // display welcome message System.out.println("Hello and Welcome to Yas's Program!"); // user input max number of cars System.out.print("Please enter the maximum number of cars: "); int maxCars = kb.nextInt(); remainingCars = maxCars; System.out.println(""); //array to keep track of cars Car [] carDatabase = new Car [maxCars]; do { //Displaying the menu until the user enters a valid number do { System.out.println("What do you want to do?"); System.out.println("1. Enter a new car to the inventory (password required)"); System.out.println("2. Change information of an existing car (password required)"); System.out.println("3. Display all Cars with the specified make and model"); System.out.println("4. Display all Cars within the given price range"); System.out.println("5. Quit"); System.out.print("Please enter your choice >
Image of page 3
"); menu = kb.nextInt(); System.out.println(); } while (menu < 1 || menu > 5); //Core part of main menu switch(menu) { // when user enters 1 case 1: //entering the password do { System.out.print("Please enter your
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 8 pages?

  • Fall '09
  • Method, Das Model, Mutator method

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes