title: Add If Else condition to an array
body: <p>I am having an isseue with the following program.</p>
  
  <p>Here is the entire code and also I recently started to learn programming and this is my first project so I am not so good at indenting and the OOP concept. If one of you experts can turn this program into OOP that will be a great help to me.</p>
  
  <pre><code>import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import java.util.*;
  
  
  class Car {
      private String make;
      private String model;
      private String regNo;
      private int deposit;
      private int rate;
  
      public Car(String newMake, String newModel, String newRegNo,int newDeposit, int newRate) 
      {
              make = newMake;
              model = newModel;
              regNo = newRegNo;
              deposit = newDeposit;
              rate = newRate;
      }
  
  
  
      public String getMake() {
              return make;
      }
  
      public String getModel() {
              return model;
      }
  
      public String getRegNo() {
              return regNo;
      }
  
      public int getDeposit() {
              return deposit;
      }
  
      public int getRate() {
              return rate;
      }
  }
  
  public class carrenta {
  
  public static void main(String[] args) {
      DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy  HH:mm");
      Date date = new Date();
      System.out.println(dateFormat.format(date));
  
  List&lt;Car&gt; carlist = new ArrayList();
  carlist.add(new Car("Toyota", "corolla", "TA7896", 1500, 1800));
  carlist.add(new Car("Toyota", "vitz", "TV9872", 1500, 1800));
  carlist.add(new Car("Nissan", "paso", "NP1543", 1500, 1500));
  carlist.add(new Car("Honda", "city", "HC4692", 1800, 1800));
  carlist.add(new Car("Honda", "civic", "HC4521", 2000, 1600));
  carlist.add(new Car("Honda", " accord", "HA5463", 2500, 2000));
  carlist.add(new Car("Mitsubishi", "lancer", "ML4521", 2000, 1500));
  
  
              Scanner input = new Scanner(System.in);
              boolean modelFound = false;
              while (!modelFound) {
              System.out.print("Enter model to rent: ");
              String model = input.nextLine();
  
              for(Car s : carlist){
          if (model.equalsIgnoreCase(s.getModel())) {
           modelFound = true;
          System.out.println("Model  " + model + " is available");
          System.out.print("Enter number of days: ");
          int days = input.nextInt();
                          System.out.println("***************Details*****************");
          int cost = (days * s.getRate()) + s.getDeposit();
          System.out.println("Deposit  DailyRate  Duration  TotalCost");
          System.out.println(s.getDeposit() + "       " + s.getRate()+ "            " + days + "        " + cost);
          System.out.print("Proceed to rent?( y/n ): ");
  
          String dec = input.next();
         switch (dec) {
              case "y":
                 System.out.println("Enter Customer Name: ");
                  String name = input.next();
                  System.out.println("Enter NIC Number: ");
                  int num = input.nextInt();
                  System.out.println("************Receipt*************");
                  System.out.println(     "     Date                               Name           NICNo         Car        RegNo    Duration   TCost");
            System.out.println(date+"           "+name + "          " + num +    "         " + model
                  + "   " + s.getRegNo() + "      " + days + "       "+cost);
                  break;
              case "n":
                  System.out.println("Serving Next Customer: ");
                  break;
                  }
      }
          else{
                  System.out.println("Please enter a valid model");
          }
          }
      }
  }
  </code></pre>
  
  <p>}</p>