Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Having a hard time with java arrays.... What am i missing here?? this is my driv

ID: 3663091 • Letter: H

Question

Having a hard time with java arrays.... What am i missing here??

this is my driver ********************************************

public class DMVDriver {

public static void main(String[] args) {

DMV dmv = new DMV(7, "Big Bertha");
dmv.addCustomer("Steve Jones");
dmv.addCustomer("Kevin Smith");
dmv.addCustomer("Shane Stevenson");
dmv.addCustomer("Johnny Lately");
dmv.addCustomer("Alexis Johnson");
dmv.addCustomer("Bob Milford");
dmv.addCustomer("Stephani Bradly");
dmv.addCustomer("Rickshaw Rundrive");
dmv.addCustomer("Kelly Strickland");
dmv.printDMV();
   }
   } // end main

*********************************************************end driver

this is what i have so far******************

import java.util.Scanner;

public class DMV {

public int NO_IN_LINE=10 ;                    // holds the max in line
public int NO_CUST_INLINE;


   String[] name = new String[10];            // array
   public DMV( int NO_CUST_INLINE)            // constuctor
{
   this.NO_CUST_INLINE=NO_CUST_INLINE;        // initialization
}
   public addCustomer(String name)
{
       int t=isInLine(name);
       if(t)
{
       System.out.println("is already in line" + name);
}
else        // adding customer into line
{
customer.add(name);
}
}
public boolean isInLine(String name) //helper function definition
{
boolean contains = false;
for(int i=0; i < customer.length; i++) //iterate the String array
{
if(customer [i].equals(name)) //check if string array contains the string
{
   contains = true;                //string found
   break;
}
}
   return contains ;          
}
}                                   // end of class

********************************************* output should read

Steve Jones is already in line.

Kelly Strickland has to wait in a chair. The line is full.

People in line for Big Bertha:

Steve Jones
Kevin Smith

Shane Stevenson
Steve Jones
Alexis Johnson
Bob Milford
Stephani Bradly
Rickshaw Rundrive
Kelly Strickland

Explanation / Answer

This is DMV.java

import java.util.Scanner;

public class DMV {

public int NO_IN_LINE=10 ;                     // holds the max in line
public int NO_CUST_INLINE = 0;


    String[] name = new String[10];             // array
    public DMV(int NO_IN_LINE)             // constuctor
{
    this.NO_IN_LINE =NO_IN_LINE;         // initialization
}
public DMV(int NO_IN_LINE, String name)             // constuctor
{
    this.NO_IN_LINE =NO_IN_LINE;         // initialization
    this.addCustomer(name);
}
    public void addCustomer(String name)
{
        boolean t=isInLine(name);
        if(t)
{
        System.out.println("is already in line" + name);
}
else         // adding customer into line
{
this.name[NO_CUST_INLINE] = name;
NO_CUST_INLINE++;
}
}
public boolean isInLine(String name) //helper function definition
{
boolean contains = false;
for(int i=0; i < this.name.length; i++) //iterate the String array
{
if(this.name[i].equals(name)) //check if string array contains the string
{
    contains = true;                 //string found
    break;
}
}
    return contains ;        
}

public void printDMV()
{
for(int i = 0; i < NO_CUST_INLINE; i++)
   System.out.print(name[i]+" ");
System.out.println();
}
}                                    // end of class


And this is DMVDriver.java

public class DMVDriver {

public static void main(String[] args) {

DMV dmv = new DMV(7, "Big Bertha");
dmv.addCustomer("Steve Jones");
dmv.addCustomer("Kevin Smith");
dmv.addCustomer("Shane Stevenson");
dmv.addCustomer("Johnny Lately");
dmv.addCustomer("Alexis Johnson");
dmv.addCustomer("Bob Milford");
dmv.addCustomer("Stephani Bradly");
dmv.addCustomer("Rickshaw Rundrive");
dmv.addCustomer("Kelly Strickland");
dmv.printDMV();
    }
    } // end main

//********************************************************end driver


If you have any further queries, just get back to me.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote