CPS 151 P1 CS1181 Project 2 - Spring 2019 Due: Friday, March 22, 11:59 pm. Upload your zipped project to the dropbox on your lab’s Pilot site. For this assignment, you will write a simulation program...

I have attached project file and 2 output images.


CPS 151 P1 CS1181 Project 2 - Spring 2019 Due: Friday, March 22, 11:59 pm. Upload your zipped project to the dropbox on your lab’s Pilot site. For this assignment, you will write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way:  delete the addfirst, addlast, and add(index) methods and instead include a single add method that adds the item in the correct (sorted) spot, smallest items at the head. Use this method header: public void add(E e)  Indicates that the generic item will have implemented the Comparable interface by specifying the class in this way: public class MySortedList> Queue: Implement a generic queue with an ArrayList as the only instance variable. The constructor will instantiate the list. Include standard enqueue and dequeue methods, as well as isEmpty, getSize, and to String. Customer: The following information should be included as private variables in the Customer class: customerNumber, storeArrivalTime, and shoppingLength. All variables are of type int. There will be NO mutator (setter) methods. Be sure your class meets these requirements: The constructor should do the following:  Set the customerNumber (use a static class variable for this)  Set storeArrivalTime (use the simClock, which will be a parameter to the constructor)  Set shoppingLength (a random number between 5 and 45) There should be accessor (getter) methods for the following:  customerNumber  storeArrivalTime  shoppingLength  checkoutArrivalTime (storeArrivalTime + shoppingLength)  checkoutLength (the integer ceiling of shoppingLength/5). Include a toString method that displays all information for the customer Implement the Comparable interface with compareTo based on checkOutArrivalTime. Cashier: extends your Queue class and includes a finishTime instance variable of type integer. finishTime will be set to 0 in the constructor. Include an accessor for finishTime as well as these methods: public boolean addcustomer(Customer c) //call enqueue public Customer serveNextcustomer (int simClock) //if the queue is empty, returns null. Otherwise, dequeues an item, sets the finish time equal to (simulation clock + customer’s checkoutLength) and returns the csutomer. Data objects needed in the driver program:  A CustomerList – a sortedList of customers representing the customers currently shopping  An array of Cashiers (checkout lanes) Output files needed:  You will need two output files: one to store the summary information and one to store details of the simulation. Other:  A simulation clock (an integer variable)  Declare other variables as needed to store the necessary counters and statistics, and to manage the simulation. Simulation procedure: 1. Declare data objects, files, etc. 2. Get input:  Number of open checkout lanes (integer, user must enter a number >= 1)  Length (in minutes) of the simulation (int, user must enter a number >= 10)  Number of customers expected to enter the store during each hour (integer between 1 and 60) 3. Initialize variables (create the appropriately-sized array of cashiers; set simulation clock to 0, number of customers to 0, etc.) 4. Begin simulation loop (a counted loop that increments the simClock each iteration until simulation length is reached; start the counter at 1):  If a new customer has arrived to the store (determined by a random function described below):  Create a new customer (use the simClock as storeArrivalTime)  Increment the number of customers created.  Add customer to customer list  If customers are ready to check out (when their checkOutArrivalTime == simulation clock)  Remove the customer from the customer list and add the customer to cashier with shortest checkout line. Keep in mind more than one customer could be ready to check out during each clock cycle.  Update cashiers. For each cashier:  If the cashier’s finishTime <= simulation clock, the cashier is available to handle another customer from the queue. if that cashier’s line is not empty:  call the servenextcustomer method for that cashier  increment number of customers served  calculate how long this customer was waiting since entering the checkout line and increment totalwaittime accordingly.  output the customer details to the details output file. 5. after the simulation loop, output all input values to the summary output file. (number of checkout lanes used, length of the simulation, number of customers expected to enter the store during each hour) 6. after the simulation loop, output all simulation statistics to the summary output file:  number of customers who entered the store during the simulation  number of customers still shopping (not in line)  number of customers waiting in a checkout line but not yet being served  number of customers who have been or are currently being served by cashiers  average wait time for all customers who have been or are currently being served (rounded to two places to the right of the decimal) 7. write a message to the console indicating that the simulation is finished, and where the simulation information can be found (state the file names for the details and summary information). sample output files are available on pilot. calculation of whether new customer has arrived (needed for step 4 above): to write the method for determining if a customer has arrived, first calculate the arrivalprobability for a new customer in any given minute of the simulation (assume each clock tick represents a minute). this can be calculated using the information input from the user regarding length of simulation in hours and number of customers arriving per hour. once you have the probability per minute, use it as follows:  calculate the arrival probability per hour (expected # of customers per hour / 60 * 100). this needs to be of type double  generate a random integer between 0 and 100  if the number is less than or equal to the arrivalprobability, assume a new customer has arrived.  if the number is greater than the arrivalprobability, no customer has arrived. generating random integers between two boundaries, inclusive: randomnum = (int) (lowerbound + math.random() * (upperbound – lowerbound + 1)); before writing the simulation portin of this project, it is important that the classes that will be used have been thoroughly tested. i suggest you do this preliminary work, writing driver programs as indicated. these driver programs are for testing only, and should not be part of your finishsed project. 1. create queue class and thoroughly test all methods with a separate driver program 2. create sorted list class and thoroughly test all methods with a separate driver program 3. create the cashier class and write a driver to thoroughly test all methods. 4. create the customer class and write a driver to thoroughly test all methods. when you come in for help on this project, your instructor or ta may ask to see your test programs, to verify that your classes work correctly. additionally, you may want to create a driver program that creates an array of cashiers and a sorted list of customers. verify that you are able to add and remove items to both the array and the list. simulation="" clock,="" the="" cashier="" is="" available="" to="" handle="" another="" customer="" from="" the="" queue.="" if="" that="" cashier’s="" line="" is="" not="" empty:="" ="" call="" the="" servenextcustomer="" method="" for="" that="" cashier="" ="" increment="" number="" of="" customers="" served="" ="" calculate="" how="" long="" this="" customer="" was="" waiting="" since="" entering="" the="" checkout="" line="" and="" increment="" totalwaittime="" accordingly.="" ="" output="" the="" customer="" details="" to="" the="" details="" output="" file.="" 5.="" after="" the="" simulation="" loop,="" output="" all="" input="" values="" to="" the="" summary="" output="" file.="" (number="" of="" checkout="" lanes="" used,="" length="" of="" the="" simulation,="" number="" of="" customers="" expected="" to="" enter="" the="" store="" during="" each="" hour)="" 6.="" after="" the="" simulation="" loop,="" output="" all="" simulation="" statistics="" to="" the="" summary="" output="" file:="" ="" number="" of="" customers="" who="" entered="" the="" store="" during="" the="" simulation="" ="" number="" of="" customers="" still="" shopping="" (not="" in="" line)="" ="" number="" of="" customers="" waiting="" in="" a="" checkout="" line="" but="" not="" yet="" being="" served="" ="" number="" of="" customers="" who="" have="" been="" or="" are="" currently="" being="" served="" by="" cashiers="" ="" average="" wait="" time="" for="" all="" customers="" who="" have="" been="" or="" are="" currently="" being="" served="" (rounded="" to="" two="" places="" to="" the="" right="" of="" the="" decimal)="" 7.="" write="" a="" message="" to="" the="" console="" indicating="" that="" the="" simulation="" is="" finished,="" and="" where="" the="" simulation="" information="" can="" be="" found="" (state="" the="" file="" names="" for="" the="" details="" and="" summary="" information).="" sample="" output="" files="" are="" available="" on="" pilot.="" calculation="" of="" whether="" new="" customer="" has="" arrived="" (needed="" for="" step="" 4="" above):="" to="" write="" the="" method="" for="" determining="" if="" a="" customer="" has="" arrived,="" first="" calculate="" the="" arrivalprobability="" for="" a="" new="" customer="" in="" any="" given="" minute="" of="" the="" simulation="" (assume="" each="" clock="" tick="" represents="" a="" minute).="" this="" can="" be="" calculated="" using="" the="" information="" input="" from="" the="" user="" regarding="" length="" of="" simulation="" in="" hours="" and="" number="" of="" customers="" arriving="" per="" hour.="" once="" you="" have="" the="" probability="" per="" minute,="" use="" it="" as="" follows:="" ="" calculate="" the="" arrival="" probability="" per="" hour="" (expected="" #="" of="" customers="" per="" hour="" 60="" *="" 100).="" this="" needs="" to="" be="" of="" type="" double="" ="" generate="" a="" random="" integer="" between="" 0="" and="" 100="" ="" if="" the="" number="" is="" less="" than="" or="" equal="" to="" the="" arrivalprobability,="" assume="" a="" new="" customer="" has="" arrived.="" ="" if="" the="" number="" is="" greater="" than="" the="" arrivalprobability,="" no="" customer="" has="" arrived.="" generating="" random="" integers="" between="" two="" boundaries,="" inclusive:="" randomnum="(int)" (lowerbound="" +="" math.random()="" *="" (upperbound="" –="" lowerbound="" +="" 1));="" before="" writing="" the="" simulation="" portin="" of="" this="" project,="" it="" is="" important="" that="" the="" classes="" that="" will="" be="" used="" have="" been="" thoroughly="" tested.="" i="" suggest="" you="" do="" this="" preliminary="" work,="" writing="" driver="" programs="" as="" indicated.="" these="" driver="" programs="" are="" for="" testing="" only,="" and="" should="" not="" be="" part="" of="" your="" finishsed="" project.="" 1.="" create="" queue="" class="" and="" thoroughly="" test="" all="" methods="" with="" a="" separate="" driver="" program="" 2.="" create="" sorted="" list="" class="" and="" thoroughly="" test="" all="" methods="" with="" a="" separate="" driver="" program="" 3.="" create="" the="" cashier="" class="" and="" write="" a="" driver="" to="" thoroughly="" test="" all="" methods.="" 4.="" create="" the="" customer="" class="" and="" write="" a="" driver="" to="" thoroughly="" test="" all="" methods.="" when="" you="" come="" in="" for="" help="" on="" this="" project,="" your="" instructor="" or="" ta="" may="" ask="" to="" see="" your="" test="" programs,="" to="" verify="" that="" your="" classes="" work="" correctly.="" additionally,="" you="" may="" want="" to="" create="" a="" driver="" program="" that="" creates="" an="" array="" of="" cashiers="" and="" a="" sorted="" list="" of="" customers.="" verify="" that="" you="" are="" able="" to="" add="" and="" remove="" items="" to="" both="" the="" array="" and="" the="">
Mar 17, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here