Programming Language Concepts Jan-Apr 2015 Assignment 2 Due Friday, 18 April, 2016 1. Write a Java program to simulate a bank teller system. There are a number of customers and a number of tellers. Each customer is handed a unique token (the customer number) in sequential order. Whenever a teller is free, she calls the next customer to be served (in order of token number). The teller prints out a message saying she has served the customer numbered X after serving customer X. You should ensure that the tellers together service all customers (without repetition), and that for each teller, the customer numbers that she serves are in ascending order. You need to create a Bank class whose constructor takes two integers as parameters, the number of tellers and the number of customers for the day. You need to print diagnostics as indicated in the included sample output. Use import java.util.concurrent.*; at the start of the program and use long threadId = Thread.currentThread().getId()%nTellers +1; to get the teller number in the appropriate place. Included is UseBank.java, a program to test your Bank class, and bank.out, the output generated in a sample run. ------------------------------------------------------------------------------ 2. A savings account object holds a nonnegative balance, and provides deposit(k) and withdraw(k) methods, where deposit(k) adds k to the balance, and withdraw(k) subtracts k, if the balance is at least k, and otherwise blocks until the balance becomes k or greater. Withdrawals can be of two types: ordinary and preferred. The implementation should ensure that no ordinary withdrawal occurs if there is a preferred withdrawal waiting to occur. Create a Account class with the following fields and methods. private int balance -- balance is a nonnegative number. public Account(int balance) -- constructor. Ensure that the balance is nonnegative. public void deposit(int id, int k) -- thread numbered id adds k to the account. Assume k is nonnegative. public void withdraw(int id, boolean isPreferred, int k) -- thread numbered id subtracts k if the balance is at least k. Otherwise block till the balance becomes >= k. Assume k is nonnegative. Withdrawals are either ordinary (signified by isPreferred = false) or preferred (signified by isPreferred = true). Your implementation should ensure that no ordinary withdrawal occurs if there is a preferred withdrawal waiting to occur. Your methods should print diagnostics as shown in the sample run included with this assignment. Use import java.util.Date at the start of Account.java, declare a variable Date date, and use date = new Date() at the appropriate places. Included is UseAccount.java, a program to test your Account class, and account.out, the output generated in a sample run. ------------------------------------------------------------------------------ --- General Instructions -- Important --- 1. Do NOT add any package declarations 2. Do NOT submit a `main' method as part of your solution. Any solutions containing a `main' method will NOT be graded. Note that we will test your solutions by supplying our own main methods in a separate file, so make sure that your implementation works when this happens. 3. Any submissions with compile errors will NOT be graded. 4. Late submissions will NOT be graded. 5. All the files comprising your solution code should be in one folder (no subfolders) named -2, where un is your username. Compress the folder as a TGZ file named -2.tgz and submit it on the Moodle page. For example, I would put all my files in a folder named spsuresh-2 and submit the compressed file spsuresh-2.tgz.