Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[JAVA] PLEASE NO HASHMAPS! CODE NEEDS TO BE SIMPLE! PLEASE SHOW OUTPUT! (1) Print all subsets for a string (2 points) Use java.util.LinkedList to print

[JAVA] PLEASE NO HASHMAPS! CODE NEEDS TO BE SIMPLE! PLEASE SHOW OUTPUT!

(1)Print all subsets for a string (2 points)

Use java.util.LinkedList to print out all subsets for a giving string. Download CState.java from Moodle.

For a given string abcdef, list out all possible nonempty subset string of

abcdef using Queue data structure.

For example: a,ab,b,abc,ac,bc, etc.

(2)Simple simulation (2 points)

Use java.util.LinkedList to create a system to simulate customers being served at the bank. Download Customer.java & Line.java from Moodle.

(a)Assume there is only one service line at the bank and it is first come, first served.

(b)The number of customer arriving at the bank varies from 1 to 5 and the number of tellers available to serve the customer varies from 1 to 4.

(c)Each customer will receive a sequential ID number when he/she join the line. The program should display the message Customer xxx joins the line to indicate the occurrence of the event.

(d)At the same token, when the teller serves the customer, the program should display Customer xxx is being served.

(e)If the line is empty, display Teller waiting.

(f)Simulate the cycle for 10 times as the end of banks business day.

(g)The service line should be empty after the bank is closed.

public class CState {

private String Prefix = new String(); private String Suffix = new String(); public CState (String Pre, String Suff) { Prefix = Pre; Suffix = Suff; } public String pre() { return Prefix; } public String suff() { return Suffix; } }

//******************************************************************* // Customer.java //*******************************************************************

public class Customer { private int id;

//---------------------------------------------------------------- // Creates a customer with the specified id number. //---------------------------------------------------------------- public Customer (int number) { id = number; }

//---------------------------------------------------------------- // Returns a string description of this customer. //---------------------------------------------------------------- public String toString() { return "Customer " + id; } }

//******************************************************************* // Line.java // //*******************************************************************

import java.util.LinkedList;

public class Line { LinkedList queue;

//---------------------------------------------------------------- // Creates a new line based on a queue. //---------------------------------------------------------------- public Line() { queue = new LinkedList(); }

//---------------------------------------------------------------- // Removes a customer from the head of the queue. //---------------------------------------------------------------- public Customer nextCustomer() { return (Customer)queue.removeFirst(); }

//---------------------------------------------------------------- // Adds a customer to the tail of the queue. //---------------------------------------------------------------- public void addCustomer(Customer person) { queue.addLast(person); }

//---------------------------------------------------------------- // Indicates whether the queue is empty. //---------------------------------------------------------------- public boolean isEmpty() { return queue.isEmpty(); }

//---------------------------------------------------------------- // Returns the number of customers in the queue. //---------------------------------------------------------------- public int size() { return queue.size(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

which three test stratagies are types of performance testing

Answered: 1 week ago

Question

Discuss the importance of workforce planning.

Answered: 1 week ago

Question

Differentiate between a mission statement and a vision statement.

Answered: 1 week ago