Hello. tutors. I needed a little more help to complete this code,…

Question Answered step-by-step Hello. tutors. I needed a little more help to complete this code,… Hello. tutors.I needed a little more help to complete this code, so I uploaded it. I think there are some parts to be fixed, but I’m not sure how to fix it, so I’d appreciate it if you could fix it.  import java.util.Date;public class Bike{   // constants   public static final double LOW_BATTERY_CHARGE = 0.2;   // instance variables   private String bikeId;   private double batteryCharge;   private boolean inUse;   private long rentalStart;   private String userName;   /**    * Full-arg constructor for objects of class Bike    */   public Bike(String bikeId, double batteryCharge, boolean inUse, long rentalStart, String userName)   {       // assign parameter values to instance variables       this.bikeId = bikeId;       setBatteryCharge(batteryCharge);       this.inUse = inUse;       this.rentalStart = rentalStart;       this.userName = userName;   }      /**    * Single-arg constructor for objects of class Bike    */   public Bike(String bikeId)   {       // assign parameter values to instance variables       this.bikeId = bikeId;       setBatteryCharge(1.0);       this.inUse = false;       this.rentalStart = 0L;       this.userName = null;   }   /**    * getBikeId method – returns current value of bikeId    *    * @return            current value of the bikeId instance variable    */   public String getBikeId()   {       return bikeId;   }   /**    * setBatteryCharge method – assigns the parameter value to batteryCharge    *    * @param  batteryCharge     new value to be stored in the batteryCharge instance variable, which must be    *                           between 0.0 and 1.0 (inclusive)    */   public void setBatteryCharge(double batteryCharge)   {       if (batteryCharge >= 0.0 && batteryCharge <= 1.0)       {           this.batteryCharge = batteryCharge;       }   }   /**    * getBatteryCharge method - returns current value of batteryCharge    *    * @return                   current value of the batteryCharge instance variable    */   public double getBatteryCharge()   {       return batteryCharge;   }   /**    * isBatteryLow method - returns a boolean indicating whether batteryCharge is considered low    *    * @return               true if current value of batteryCharge instance variable is at or below    *                       the LOW_BATTERY_CHARGE constant value, false otherwise    */   public boolean isBatteryLow()   {       return batteryCharge <= LOW_BATTERY_CHARGE;   }   /**    * isInUse method - returns a boolean indicating whether Bike is rented (i.e. in use)    *    * @return          current value of the inUse instance variable    */   public boolean isInUse()   {       return inUse;   }   /**    * getRentalStart method - returns current value of rentalStart (expressed as milliseconds)    *    * @return                 current value of the rentalStart instance variable    */   public long getRentalStart()   {       return rentalStart;   }   /**    * getUserName method - returns current value of userName    *    * @return              current value of the userName instance variable    */   public String getUserName()   {       return userName;   }   /**    * rent method        - assigns values to inUse, userName and rentalStart indicating that the Bike    *                      is now rented. Note that inUse MUST be false to begin with.    *    * @param  userName     user name or ID to be stored in the userName instance variable    */   public void rent(String userName)   {       if (!inUse)       {           inUse = true;           this.userName = userName;           rentalStart = System.currentTimeMillis(); // the rental clock starts now       }   }   /**    * unrent method      - resets inUse, userName and rentalStart values indicating that the Bike is    *                      no longer rented. Note that inUse MUST be true to begin with.    *    * @return              elapsed milliseconds from rentalStart up to the time this method is invoked    */   public long unrent()   {       long elapsed = 0;       if (inUse)       {           elapsed = System.currentTimeMillis() - rentalStart;           inUse = false;           userName = "";           rentalStart = 0L;       }       return elapsed;   }   /**    * equals() - overrides Objects.equals to determine Bike equality by comparing bikeId strings    */   @Override   public boolean equals(Object obj)   {       if (obj == null)       {           return false;       }       if (!Bike.class.isAssignableFrom(obj.getClass()))       {           return false;       }       final Bike other = (Bike) obj;       if ((this.bikeId == null) ? (other.bikeId != null) : !this.bikeId.equals(other.bikeId))       {           return false;       }       return true;   }   /**    * hashCode() - overrides Objects.hashCode to derive a Bike hashcode using bikeId    */   @Override   public int hashCode()   {       int hash = 3;       hash = 53 * hash + (this.bikeId != null ? this.bikeId.hashCode() : 0);       return hash;   }   /**    * toString method - returns a readable representation of Bike state    *    * @return           a String containing nicely formatted Bike instance variable values    */   @Override   public String toString()   {       String result = String.format("%7s  %6.0f%%", getBikeId(), getBatteryCharge() * 100.0);       if (isInUse())       {           result += String.format("  Rented at %1$tH:%1$tM to %2$s", new Date(getRentalStart()), getUserName());       }       return result;   }}   import java.util.*;import java.io.*;public class BikeApp {   public static void main (String [] args) throws IOException   {       // Create a Scanner object attached to the keyboard       Scanner input = new Scanner (System.in);       List bikeList = new ArrayList<>();       String fileName = “”;       System.out.println(“*** Welcome to R&R E – Bike Rentals ***”);       System.out.println(“Enter bike data filename: “);       fileName = input.nextLine();       bikeList = loadBikes(fileName,bikeList);       while (true) {           System.out.println();           printAllBikes(bikeList);           int option = showMenu(input,bikeList);           input.nextLine();           switch(option) {               case 1:                   rentBike(input,bikeList);                   break;               case 2:                   returnBike(input,bikeList);                   break;               case 3:                   chargeBike(input,bikeList);                   break;               case 4:                   saveBikes(fileName,bikeList);                   System.out.println(“Good bye!”);                   System.exit(0);                   break;           }       }   }   private static void printAllBikes(List bikeList) {       System.out.println(“Bike IDtBatterytRental Status”);       System.out.println(“——-t——-t————-“);       for (Bike b : bikeList) {           String rentalStart = “”;           if(b.getRentalStart() > 0) {               rentalStart = String.valueOf(b.getRentalStart());           }           System.out.printf(“%st%d%%t%s%n”,b.getBikeId(),               (long) (b.getBatteryCharge() * 100),               rentalStart);       }   }   private static int showMenu(Scanner input, List bikeList) {       System.out.println(“What would you like to do (1=Rent, 2=Return, 3=Charge Battery, 4=Exit)?”);       System.out.print(“Enter your option number: “);       return input.nextInt();   }   private static List loadBikes(String fileName, List bikeList) throws IOException{       Scanner inData = new Scanner(new File(fileName));       inData.useDelimiter(“,|rn”);       while(inData.hasNextLine()) {           String [] tokens = inData.nextLine().split(“,”);           String bikeId = tokens[0];           double batteryCharge = Double.parseDouble (tokens[1]);           boolean inUse =               Boolean.parseBoolean(tokens[2].trim().toLowerCase(Locale.ROOT));           long rentalStart = Long.parseLong(tokens[3]);           String username = “”;           if (tokens.length == 5) {               username = tokens[4];           }           bikeList.add(new Bike(bikeId, batteryCharge, inUse,rentalStart,username));       }       return bikeList;   }   private static void saveBikes(String fileName, List bikeList) throws IOException {       new FileOutputStream(fileName).close();       PrintWriter writer = new PrintWriter(new FileWriter(fileName));       for (Bike b : bikeList) {           String username = “”;           if(b.getUserName().length() > 0) {               username = “,” + b.getUserName();           }           writer.printf(“%s%n”,username);       }       writer.close();   }   private static Bike findBike(String bikeId, List bikeList) {       for (Bike b : bikeList) {           if(b.getBikeId().equalsIgnoreCase(bikeId)) {               return b;           }       }       return null;   }   private static void rentBike(Scanner input,List bikeList) {       System.out.print(“Rent a bike. Enter bike ID: “);       String bikeId = input.next();       Bike foundBike = findBike(bikeId, bikeList);       if(foundBike != null) {           if(foundBike.isInUse()) {               System.out.println(“Bike ” + bikeId + ” is in use and cannot be rented.”);           }else if (foundBike.isInUse() && foundBike.isBatteryLow()){               System.out.println(“Bike ” + bikeId + ” has a low battery and cannot be rented.”);               System.out.println(“Press [Enter] to continue…”);           } else {               System.out.println(“Enter customer name or email: “);               String cusEmail = input.next();               System.out.println(“Bike ” + bikeId + ” rented to ” + cusEmail);                System.out.println(“Press [Enter] to continue…”);           }       }else {           System.out.println(“Sorry. Bike “+ bikeId + ” is not found.”);           System.out.println(“Press [Enter] to continue …”);       }   }   private static Bike returnBike(Scanner input, List bikeList) {       System.out.print(“Return a bike. Enter bike ID: “);       String bikeId = input.nextLine();       Bike foundBike = findBike(bikeId, bikeList);       if (foundBike.isInUse()) {           System.out.println(“Bike “+ bikeId + ” returned. Minutes used: ” +  ”    Cost : “);       }       else  {           System.out.printf(“Bike %s does not need to be returned.”, bikeId);           System.out.println(“Press [Enter] to continue…”);       }       return null;   }   private static void chargeBike(Scanner input,List bikeList) {       System.out.print(“Charge a battery. Enter bike ID: “);       String bikeId = input.nextLine();       Bike foundBike = findBike(bikeId, bikeList);       if(foundBike != null) {           if(foundBike.isInUse()) {               System.out.printf(“Bike %s is rented and cannot be charged.”,bikeId);               System.out.println(“Press [Enter] to continue…”);               foundBike.setBatteryCharge(1.00);           }else{               System.out.println(“1 charge unit applied to bike ” + bikeId + “.”);               System.out.println(“Press [Enter] to continue…”);           }       } else {           System.out.printf(“Sorry, Bike %s is not found.%n”, bikeId);           System.out.println(“Press [Enter] to continue…”);       }   }}  From here on out, it’s helpful information. Image transcription textRikki and RJ have decided to start a smallE-Bike rental business in a nearby resort. Theyhave decided that no advance re… Show more… Show moreImage transcription textHere are some additional requirementsthat should be implemented: Bikes withvery low batteries will be … Show more… Show moreImage transcription textA1 x ‘4’ fr BE11 A C BE11 1 FALSE 0 2BE12 1 FALSE 0 3 BE13 1 FALSE 0 4BE14 0.9 FALSE 0 5 BE15… Show more… Show more This is the sample that needs to be completed.Image transcription textBEIE 100% BE19 100% BE20 55% BE21 100% BE22 100%What would you like to do {1=Rent, 2=Return, 3=ChargeBattery, 4=Exit]? Enter your option number: 3 C… Show more… Show moreImage transcription textBE11 100% BE12 100% BE13 100% 3E1! 90% BE15 100%Rented at 12:43 to steve?dEhotmail.com BEl? 100% 3E1? 16%3318 100% BE19 100% BE20 100% BEZl 100% B… Show more… Show more  Computer Science Engineering & Technology Java Programming ACDCC CMPP269 Share QuestionEmailCopy link Comments (0)