Queues
This programming exercise introduces the Queue data structure. The students must create all the necessary methods for the queue and use the queue in a Java program.
Step 1 - Create a new project in Netbeans
Use the following naming convention: “Module4_Lastname_Assignment1”.
Step 2 - Build a solution
You have been asked to create a customer service program for a new phone store that will be opening soon. Since this company anticipates being the agent for a rising new product that will be able to host the most popular video games–always released at midnight on the eve of the anticipated announcement date–they want a customer service module that will help them manage the customers as they arrive. Customers will be added to the queue as they arrive, removed once they have been served. Sometimes the queue will be search to determine who is there. As a prototype for this system, you are to use the linked list created in Assignment 3.1 to create a queue class and a test program that can handle this new system. The queue class must include a method to insert elements into the queue, remove elements from the queue, look at the first and last element of the queue without removing the elements from the queue, and search for an element in the queue. Use the following algorithm to simulate a simple version of the new system.
Choose a random integer between 1 and 5 to determine
the minutes at which a customer arrives.
When a customer arrives, choose a random integer between 1 and 5 to
determine the number of minutes that the customer must remain in
the checkout line.
Repeat the two steps for a 12 hour (720 minute) simulation.
Run the simulation again with a random integer of 1 and 3 to
compare the number of customers in the checkout line against the
original 12 hour simulation.
Step 3 - Compile and execute your code
Be sure to test the solution using a set of input data that demonstrates that your solution is correct. Take a screen shot showing the output from your Java program.
Step 4 - Submit your assignment
When you have completed your assignment submit a copy (source code and screen shot) below. Be sure to include your test data.
You can create project in Netbeans naming “Module4_Lastname_Assignment1” and build a solution.
I am providing you solution in C++,if you know JAVA ,you can easily covert the code by simply changing input and output methods. The main logic will remain same in both the case
I will comment each pace in code where there will be some special logic.
#include<iostream>
#include<stdio.h>
#include <unistd.h> //for sleep()
#include<stdlib.h> //for srand() and rand()
using namespace std;
struct node
{
int data;
node *next;
}*front = NULL,*rear = NULL,*p = NULL,*np = NULL;
void push(int x)
{
np = new node;
np->data = x;
np->next = NULL;
if(front == NULL)
{
front = rear = np;
rear->next = NULL;
}
else
{
rear->next = np;
rear = np;
rear->next = NULL;
}
}
void display(){
if(front==NULL){
cout<<"Underflow."<<endl;
return;
}
node *temp=front;
//will check until NULL is not found
while(temp){
cout<<temp->data<<" ";
temp=temp->next;
}
cout<<endl;
}
int remove()
{
int x;
if(front == NULL)
{
cout<<"empty queue\n";
}
else
{
p = front;
x = p->data;
front = front->next;
delete(p);
return(x);
}
}
int main()
{
int n,c = 0,x;
cout<<"As we are doing simultion for 720 mins\n";
srand(time(NULL)); // help in unique random number generation
int cusArrivalTime =rand()%5;
if(cusArrivalTime<1)
cusArrivalTime=1;
int cusWaiTime=rand()%5; //time customer remain in the checkout line
if(cusWaiTime<1)
cusWaiTime=1;
cin>>n;
int totcu=720/cusArrivalTime; //total customer arrived in 720 mins
while (c < totcu)
{
cout<<"Enter the customerID to be entered into queue\n";
cin>>x;
push(x);
sleep(cusArrivalTime); //sleep the insertion till customer arrival time ,it is in sec here
c++;
}
cout<<"\n\nRemoved Values\n\n";
while(true)
{
if (front != NULL)
{
cout<<remove()<<endl;
sleep(cusWaiTime); //checkout customer from queue after every cusWaitTime determined randomly.
}
else
break;
}
return 0;
}
I think above code will help you in making your project .If you find any difficulty in understanding the code ,you can ask me through comments.
Queues This programming exercise introduces the Queue data structure. The students must create all the necessary...
Needs Help with Java programming language For this assignment, you need to 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...
Write a program that simulates a checkout line at a supermarket. The line is a queue object. Customers (i.e., customer objects) arrive in random integer intervals of from 1 to 4 minutes. Also, each customer is serviced in random integer intervals of from 1 to 4 minutes. Obviously, the rates need to be balanced. If the average arrival rate is larger than the average service rate, the queue will grow infinitely. Even with “balanced” rates, randomness can still cause long...
Java Project 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...
USE JAVA PROGRAMMING LANGUAGE
See all photos + Add to a ♡ Search Edit & Create Share . Benny the Barber owns a one-chair shop. They told Benny that customers are not happy with waiting in lines and not get processed in order they arrived. As computer scientist, you are going to help Benny to write a Java program to manage waiting lines and to process customers in the same order they arrive. Here are the functional requirements of the...
C++
Sample run might look like this:
How many minutes should the simulation run? 10
Running simulation for 10 minutes.
minute 1: nothing happens
minute 2: customer 1 arrives and will need 3 minutes to check out
minute 3: nothing happens
minute 4: customer 2 arrives and will need 1 minute to check out
minute 5: customer 3 arrives and will need 1 minute to check out
minute 5: customer 1 has checked out
minute 6: customer 2 has checked...
This is Python programming to develop a multithread program. Please follow the step below. 1. You need to develop a multithread program in Python to simulate a checkout in supermarket. The process of simulation will last for T1 seconds. You do not need to consider thread safety. 2. An integer sequence t is used to record the remaining waiting time for each customer. 3. One thread which runs every one second is used to simulate the processing of the checkout....
Hello, I am having some trouble with a supermarket checkout simulation program in C++. What I have so far just basically adds customers to the queue and prints when they arrive. I am struggling with how to implement a way of keeping track of when a given customer finishes(I will attach what I have so far). I had already created queue and node classes (with headers and cpp files) that I modified in my attempt. I would be very grateful...
Queues and Stacks Purpose: To review queues and stacks in Java, and to use the built-in Stack class and Queue interface. The Stack class is a generic class containing these methods: public void push(E value) - pushes a new value onto the Stack public E pop() - pops the next value off of the stack and returns it; throws EmptyStackExceptionl if stack is empty public E peek() - returns the next value on the Stack but does not pop it...
PLEASE DO NOT COPY CODE FROM OTHER QUESTIONS POSTED WITH THIS. THAT IS C++ NOT PYTHON Please follow the step below. 1. You need to develop a multithread program in PYTHON to simulate a checkout in supermarket. The process of simulation will last for T1 seconds. You do not need to consider thread safety. 2. An integer sequence t is used to record the remaining waiting time for each customer. 3. One thread which runs every one second is used...
In Java, create a program implementing the functionalities of a standard queue in a class called Queue3503. You will test the functionalities of the Queue3503 class from the main() method of the Main class. In a queue, first inserted items are removed first and the last items are removed at the end (imagine a line to buy tickets at a ticket counter). Do NOT change your class name from "Main". The Main class should come first in your code. Your filename should be "Main.java". The Queue3503 class will contain:...