Bank Queue Simulator

Jul 13, 2014

I am doing a bank queue simulator program which will figure what will happen in 100 minute where 0 to 2 customers comes every minute. 3 counters will handle these customers each counter will poll the customer after 3 minutes.my problem is queue.poll()is not working in counter method and it is adding null values to the queue in the same method. when i add while customers.isEmpty(); the program will not work i do not know why

package dataalgo;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
public class customer {

[code]....

View Replies


ADVERTISEMENT

Making Coin Star Simulator

Oct 13, 2014

I have been tasked with creating a coin Star simulator. This accomplishes which accomplishes the following tasks:

Prompts the user to enter coins:

(example inputs): (Note, these can't be like a numerical input followed by a word input, it needs to be one line)

4 quarters
3 dimes
0 pennies

All of which would be allowed inputs.

If an incorrect format is used it should tell the user to use the correct format of number space cointype

After every new input it should give a running total of the current money the system has stored.

this loop should continue until the user enters the phrase "finish"

Then, this system should output the money (minus 9.1% fee) in the largest denominations possible (up to $20)

So if the total came to $ 131.33 (after fee)

It should output:

6 twenties 1 tens 0 fives 1 singles 1 quarter 0 dimes 1 nickle 3 pennies.

and then maybe some cheeky text about how the machine stole your money.

The actual coding for me however is very difficult as I really don't know how to convert the string input from the user into usable numerical and substrings for the calculations.

I have some basic skeleton code worked out, but its only designed to run once.
 
import java.util.Scanner;
 public class CoinStar {
Scanner input = new Scanner(System.in);
public static void main(String[] args) {
/** this first section is supposed to take the string from the user and separate it into two substrings,
* one integer, one word string
*

[Code] ....

View Replies View Related

Java Network Simulator - Specifying Jar Class Path

Sep 4, 2014

I have downloaded jns-1.7 & tried to run an example program "Simulator.java" by specifing the jar classpath while compiling as "javac -cp <path-to-jns-jar-file> Simulator.java". But i got 21 errors as follows:

Simulator.java:3: error: package jns.command does not exist
import jns.command.Command;
^
Simulator.java:4: error: package jns.element does not exist
import jns.element.Element;

[Code] ...

21 errors

I am trying my hand on JNS as i need to deveop a key-distribution scheme (random Key-Distribution scheme) using a simulator. As i have experience in java, i thought to use JNS instead of NS2/NS3 which seems very complex to me.

View Replies View Related

GUI Bank Account Sorter

Apr 26, 2015

I have an assignment in which I have to:

1. Create a bank file with at least 10 records that include an id#, balance, and last name
2. Create another file that will read these records and then create an array of Bank Account objects
3. Create checkboxes that allow the user to select how they want the data sorted
4. List the total number of accounts at the bottom of the GUI

I've created the file no problem that actually writes the ten records. I was able to have the files be read sequentially with System.out.println(), but I can't figure out how to convert these into an array of Bank Account objects and have them show up in a scroll pane. I tried using string builder and array builder, but I couldn't figure out how to turn them into components. I then tried making an Account class to have them be sorted with comparators, but I had the same problem of actually getting them into the scroll pane. Also, as soon as I added in those methods for the GUI, the while loop wouldn't display the array information in system.out.println. Here is my code for the GUI that doesn't display anything with println ...

import java.nio.file.*;
import java.io.*;
import java.nio.file.attribute.*;
import static java.nio.file.StandardOpenOption.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

[Code] .....

View Replies View Related

Bank Account With Abstraction

May 25, 2014

I'm working on this weeks assignment and I've gotten stuck on passing information from one class to another. We are working with abstract classes this week, and the BankAccount class is the Abstract class that is extended by the CheckingAccount and the SavingsAccount classes. The Bank class is where the user inputs his/her information to process the commands. How can I work this to where the instructions are passed from the main in the Bank class to the different Account classes to actually perform the instructions?

BankAccount:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package bankaccount;
abstract class BankAccount {
private final BankAccount acctID;
private int acctBalance = 0;
public BankAccount checking;
public BankAccount savings;

[Code] ....

I can attach a PDF of the instructions if that will provide additional insight to this. I'm sure I'll ask additional questions as we go, but I'm trying to get this to work right and figure out what I'm doing wrong.

View Replies View Related

Bank Account - Printing Out Transactions

Apr 21, 2014

public class BankAccount
{
String name;
int accountID;
double balance;
}
public void setAcct ( String nam, double acctID)

[Code] ....

1. Create a class called BankAccount
a. It will be a generic simple type of BankAccount

2. BankAccount will contain variables to store:
a. the owner/owners of the account
b. an account id
c. it may contain other basic information (up to you)

3. BankAccount will contain methods that will allow you to:
a. Set the account owners information
b. Deposit money
c. Withdraw money
d. Set balances
e. Print out transactions (think more like an atm each time an action is taken it gets printed)

4. BankAccount will contain its own main()
a. At least 2 BankAccount objects will be created and ALL of their methods called .

What to do for the print out transactions

View Replies View Related

Adding AccountID To Bank Account Object

Jul 11, 2014

When I try to print out the account Id for each account object, the id is always 1. But it should be 1,2,3,4,5....all the way to the number of the account generated.My question is am I missing something in the constructor or in the main method?? I am new to programming.The main method create an array of account objects and generate random balances into each account object.

import java.util.Scanner;
public class Bank {
public static void main(String[] args) {
Scanner userInput=new Scanner(System.in);
System.out.print("Enter the number of accounts to generate: ");
int numOfAccount=userInput.nextInt();

[code]....

View Replies View Related

Bank Account With Methods / Inheritance And Overloading

Apr 23, 2014

What I have done wrong

public class BankAccount
{
String name;
int accountID;
double balance;
public void setAccount( String username, int ID, Boolean isJoint)

[Code] ....

View Replies View Related

Bank Program For Java - Reading From TXT File?

Oct 7, 2014

I am trying to make a bank program that reads to .txt files, one that has the right format and one that has the wrong format. This is part of my problem I do not know how to do this. I also do not know why my code works if I input "account" rather than "account.txt" which is supposed to be the right thing.

Let me present my code that I have so far:

// File: BankAccount.java
import java.util.Scanner;
import java.io.IOException;
public class BankAccount
{
private int accountNumber;
private double balance;

[Code] ....

View Replies View Related

Bank Account - Balance Must Be A Floating Point Number

Sep 21, 2014

Develop the class “Account” to be used by a bank. The Account class should have a single instance variable “balance”. Remember that balance must be a floating point number. The required methods for the Account class are shown below.

The Account class “debit” method should return a Boolean and should not allow an overdraft. If a withdraw greater than the current balance is attempted, the function should immediately return “false” and do nothing else.

Develop a test class to thoroughly test all aspects of the Account class. DO NOT change the class name or instance variable name given or the required method names as detailed below.

Account
1 constructor with no parameters (default balance to 0)
1 constructor with a balance parameter
setBalance method
getBalance method
credit method
debit method

I have the test class done, I won't need to put that in till later. My main problem is I'm not sure how I'm going to be able to get debit and setBalance to work together with each other.

public class Account
{
protected double balance;
// Constructor to initialize balance
public Account( double amount ) {
balance = amount;

[Code] ....

You can see I'm stressed out by not reading over my code. I already have the "Debit" in use, just have to change it. Which I did.

View Replies View Related

Bank Account Program - Processing User Input

Oct 28, 2014

So the assignment is as follows. Develop a new class called BankAccount. A bank account has the owner's name and balance. Be sure to include a constructor that allows the client to supply the owner's name and initial balance. A bank account needs - accessors for the name and balance, mutators for making deposits and withdrawals. I have the following code :

import java.util.Scanner;
public class BankAccount{
public static void main(String [] args){
Scanner reader = new Scanner(System.in);
double name;
double balance;
double deposit;
double withdrawl;

[Code] ....

I am having trouble with my if statements. I don't know how to link the number 1 & 2 keys to deposit and withdrawal actions. Plus I am supposed to have a while loop yet don't know how to implement this so that the while loop will ask the user if they would like to make another transaction after either depositing or withdrawing.

View Replies View Related

Bank Account Simulation - ResultsModel Cannot Resolve To A Type

Mar 12, 2015

I have serious errors. I am trying to design a Bank Account Simulation. My various codes are as below.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.io.*;
public class Display2 extends JFrame //implements ActionListener

[Code] ....

ERROR: ResultsModel cannot be resolved to a type

View Replies View Related

JSP :: How Bank Sites Throw User To Session Expire Page By Clicking On Browser Refresh / Back Buttons

Jun 20, 2012

I got one task from my manager, regarding browser back button, refresh button. He asks me the web application has to work like Banks site... means if I refresh or click on Back button(Browser's) then it has to throw the user out of session, I checked lot in internet. But I found like only disabling back button of disabling F5 keys like that. But he’s not accepting that.

How to approach for this? Can we throw the user out of session when he clicks on browser back button or refresh button. I think its possible . But i don't know how to implement.

View Replies View Related

EJB / EE :: Same Listener MDB For Different Jms Queue?

Feb 21, 2014

Is it possible to define the same message driven bean as a listener to different queues?

The goal being to define different redelivery configuration for different kind of messages, but handle them all through a single deployment MDB for unity/entity purposes.

The other option is to have many MDBs targeted to the same source code.

View Replies View Related

Delete From Queue Not Working

May 29, 2014

leaveQ method does not work..To see the other files related to these code click here:(Its a dropbox location) URL....Java Code:

public class CustomerQ {
private int MaxLength;
private int totalCustomers;//assuming #of customers served
int Qlength;
Customer cus;
LinkedList4Q cus4Q;

[code]....

View Replies View Related

Implement A Priority Queue

Apr 15, 2014

Implement a priority queue based on a sorted linked list. The remove operation on the priority queue should remove the item with the smallest key.

View Replies View Related

Double Ended Queue

Jan 7, 2015

implement Double Ended Queue?????

import java.util.*;
public class DoubleEndedQueueImplHW22 {
ArrayList<Integer> deque = new ArrayList<Integer>();
public void insertFront(int a){
System.out.println("adding at front: "+a);
deque.add(0,a);
System.out.println(deque);

[code]....

View Replies View Related

Implementation Of Immutable Queue

Nov 12, 2014

The following codes shows an implementation of an enqueue function of a FIFO immutable queue, and the output result shows the String "c".

I don't understand why since I expected it should be null.

The head and the tail of an ImmutableQueue Object are two separate queue, and each time I call the enqueue function, it just return a new object with a new tail, however, the head is not modified except the first two times I call the function.

Therefore, I expected head.next.next should be a null element, but the result is not like that.

public class ImmutableQueue<E> {
private int size =0;
public Queue<E> head;
public Queue<E> tail;
public ImmutableQueue(){}
private ImmutableQueue(Queue<E> hd, Queue<E> tl){
head=hd;
tail=tl;

[Code] ....

View Replies View Related

Print Queue Using Priority Q Simulation?

Nov 28, 2014

I have a class "ExecuteJob" which has Print Q in the form of Priority Q.

You can keep adding job to the Q by calling one of the method in the class. However, and object cant do things simultaneity can it? While im adding a new job to the print queue, can it be executing and existing job in the print Q.

To achieve that, I would need to implement process and threads? I believe am I right? So that adding a job is independent to being removed?

View Replies View Related

Finding Palindromes From Stack And Queue?

Apr 30, 2015

I'm trying to create a class that takes an String from a Stack and checking if it's a palindrome than taking a another String from a queue and checking if that is also a palindrome.

import java.util.Stack;
public class Palindrome {
 public static void main(String[] args) {
// TODO Auto-generated method stub
 String enteredLine;
int leftStack, rightStack;
int leftQueue, rightQueue; 
PalinedromeArray stack1 = new PalinedromeArray();

[code]....

View Replies View Related

Processing Queue Containing Dissimilar Messages

May 25, 2014

I am new to Java/OOP in general, and am trying to implement a multi-threaded system that contains a master thread, and a set of worker threads that are heterogeneous in the work they do. Once they complete the work, the workers indicate to the master by posting the result on to its queue. Here is the problem. The results of each type of work is different, and the master has to process each differently. In C (which I'm familiar with), this can be achieved by having a message type that is a union of all the expected messages, and by using a switch statement.

I thought of doing something similar in Java, by using instance of on each incoming message (each individual message class having been subclassed from a super message class) , and doing switch on that, but it doesn't seem to be the OO way to do things. The only other way I could think of was to implement an abstract method to get the type of each message, and then use the type in a switch statement, or if-then-else. Is there some other Java idiom to do this kind of processing? Also, if this is an acceptable method, why is it superior to using the reflection to find out the message type (instead of using the abstract getType())?

The message types look similar to the code below:

abstract class Message {
abstract String getType();
} class Result1 extends Message {
ResultType1 content;
String getType() {

[Code] ....

View Replies View Related

Priority Queue Implementation Using Heap / BST

Dec 4, 2014

I am in the process of implementing Priority queue, as I understand that there are many data structures you could use to implement. I implemented it with the an array, which it works absolutely fine. However I have limitations on what collections I can use from the collections classes. I fact I cant use any of the collections classes. Meaning I cant use array.

I’m trying to implement Priority Queue using heap. And implementing heap using binary trees. But however I have a few questions which I need to clarify and I cant think of any other way of resolving it. Ofcourse I can implement my own simple array class using linked list.

Inserting into heap would be quite simple, as I just need to find the right last position from left to right leaf to insert the node into the tree. However after inserting, you may want to make sure that leaf node values are > than root node. Therefore, the root node will always be with the highest priority.

I call these steps where you compare from top down as bubbledown and bubbleup. To do this I really need a for each node within the treee node to have attribute pointing to its root node. So in case of bubbleup I always have a pointer for a given node to its root, without it would mean I would to traverse through the entire tree to identify its root. Which I believe is very inefficient.

Or have I taken this completely wrong? Or is it the case that heap are only best with arrays and therefore use array (by implement it using linked list?)

View Replies View Related

Implementing A Thread-safe Queue

Jul 10, 2014

I have situation where a user can request java server to send a value to an embedded device, and if the device is asleep, that value needs to be stored in a queue until the device wakes up and sends a position to java server, at which point the server checks if there is a value in the queue and if there is, it then sends that value to the device. The maximum size of the queue is 1 for now. And if the user makes continuous requests to java server, the old value is removed and the new value is added.

Initially I was looking into BlockingQueue, but the problem with that is, well, it blocks. queue.put(value) will block if queue is full, and queue.take() will block if queue is empty. I can't have something that blocks. When the device responds to server, server checks if value is in queue, if it is not then the server carries on the rest of its responsibility. Thus, I then entertained ConcurrentLinkedQueue. While queue.offer(value) and queue.poll(); allow you to add and remove values respectively from the queue without blocking, it does not allow you to set a maximum size limit of the queue. My queue must have a maximum size limit and it has to always be the newest value the user submits to the queue (where old values are removed).So this is what I came up with:

Java Code: class Unit {
private List<Integer> cmdQueue;

public Unit(){
cmdQueue = Collections.synchronizedList(new LinkedList<Integer>());

[code]....

I use Collections.synchronizedList, as I do here, do I still need to use synchronize as I did above?

View Replies View Related

Can't Get GUI Program To Print Out Queue List

Apr 11, 2014

I have been working on this Java Gui program and i cant get it to print to the textbox correctly.i originally had it displayed in a dialog window but it would print one integer a time in a seperate window.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
import java.io.*;

[code]....

View Replies View Related

Changing Item Positions In A Queue

Nov 3, 2014

So I got an interesting challenge today. I think logically I know what I have to do but I'm at a complete loss as for the actual coding implementation. So I have to develop this method called moveToBack(T entry). What this is meant to do is as implies, move entry to the back of my queue. As simple as it sounds, I know that I cant just move its position that simple. I know that I'll have to essentially remove whatever the desired value is, and then re-add it to the back of the queue. The interesting problem with this, however; is that I know that the FIFO property exists for queue's.

So if the desired entry to be moved is at the 3rd position of 4, I'd have to remove positions 1 and 2 to finally get to 3. But I want it to keep those values still. So I assume what I'll have to do is remove each element of the queue (it'll only be 5 entries max for the purpose of the project) and save it somewhere, then empty the queue and finally add the elements back in while waiting and putting the desired element to the last position.

If that's the case, I'm really curious on how I would do this. I have 4 files, 2 interfaces, the main class that contains the methods and what not for the queue, and a 4th class that'll be used for running test data and testing the methods of the program. Now, I wont add the interfaces code below because those are fine and all methods that need to be added are. I just gotta improve my moveToBack method so that it does what its supposed to. (I know I should have exceptions instead of my very poor else statements, but for this project it's not necessary.)

public abstract class NoDuplicatesQueueWilson<T> implements NoDuplicatesQueueInterfaceWilson<T>
{
private int MAX_QUEUE = 5; // Default array size, small for testing purposes
private T[] items; // The array of the queue.
private int front; // The first entered item of a queue.
private int back; // The last entered item of a queue.
private int count; // A counter.

[Code] ....

View Replies View Related

FIFO - Implementation Of Immutable Queue

Nov 12, 2014

The following codes shows an implementation of an enqueue function of a FIFO immutable queue, and the output result shows the String "c". I don't understand why since I expected it should be null.

The head and the tail of an ImmutableQueue Object are two separate queue, and each time I call the enqueue function, it just return a new object with a new tail, however, the head is not modified except the first two times I call the function.

Therefore, I expected head.next.next should be a null element, but the result is not like that.

public class ImmutableQueue<E> {
public Queue<E> head;
public Queue<E> tail;
public ImmutableQueue(){}
private ImmutableQueue(Queue<E> hd, Queue<E> tl){
head=hd;
tail=tl;

[Code] ......

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved