How To Create Withdraw / Deposit Feature So It Can't Exceed Maximum Limit
Nov 25, 2014
So lets say I got maximum of 20 deposit, I want to create a method/function (idk what proper name for it is) so that you cannot deposit more than 20 nor withdraw more than you have in your account, so this function checks your account, if your total is for example 18 and you're trying to deposit 10, it rejects it and doesn't add to your total and pops up with a message, vice versa for withdraw.
This is what I have so far
Not I already have the maximum limit + total feature created just not displayed here
public void depositMoney (int dMoney) {
if(DMoney > 0 ) {
totalMoney = totalMoney + dMoney;
}
else {
System.out.println("Please insert money more than 0");
[Code] .....
View Replies
ADVERTISEMENT
Nov 25, 2014
So lets say I got maximum of 20 deposit, I want to create a method/function (idk what proper name for it is) so that you cannot deposit more than 20 nor withdraw more than you have in your account, so this function checks your account, if your total is for example 18 and you're trying to deposit 10, it rejects it and doesn't add to your total and pops up with a message, vice versa for withdraw.
This is what I have so far . Not I already have the maximum limit + total feature created just not displayed here
Java Code:
public void depositMoney (int dMoney) {
if(DMoney > 0 ) {
totalMoney = totalMoney + dMoney;
} else {
System.out.println("Please insert money more than 0");
[Code] ....
View Replies
View Related
Dec 4, 2014
This programs is a bank account application that allows users to deposit, withdraw, and transfer money to another accounts using GUI interface. the program works perfect except transferTo part, where if user clicks the transferTo button and choose the beneficiary account and enter the amount it wont transfer to that account.
account class
import java.text.NumberFormat;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
public abstract class Account {
String number;
String name;
GregorianCalendar openDate = new GregorianCalendar();
[Code] .....
View Replies
View Related
Mar 5, 2015
We are running a set of unit tests using the latest ojdbc 7 driver and the highest open cursor keeps going up, until it hits our 300 limit, then throws the cursor limit exception. If we run these tests using ojdbc 12.0.1.1, the highest open cursor stays at 17 and doesn't cause this exception.
The query used to monitor these cursors is below:
SELECT max(a.value) as highest_open_cur, p.value as max_open_cur FROM v$sesstat a, v$statname b, v$parameter p WHERE a.statistic# = b.statistic# and b.name = 'opened cursors current' and p.name= 'open_cursors' group by p.value
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
Java 8 version 31
View Replies
View Related
Jan 31, 2015
I'm trying to create a circular array which prints out 8 numbers that increase by one and don't exceed 9. If they do, the remaining numbers are printed from 0 on-wards. I have code below which does this job, but it doesn't really use an array to loop back.
Java Code:
package Practice;
public class Practice
{
public static void main(String[] test)
{
number(7);
number(9);
[code]...
View Replies
View Related
Mar 12, 2015
I am tring to run LDA to generate some topics from txt files as the following one:
Document1 label1 forest=3.4 tree=5 wood=2.85 hammer=1 colour=1 leaf=1.5
Document2 label2 forest=10 tree=5 wood=2.75 hammer=1 colour=4 leaf=1
Document3 label3 forest=19 tree=0.90 wood=2 hammer=2 colour=9 leaf=4.3
Document4 label4 forest=4 tree=5 wood=10 hammer=1 colour=6 leaf=3
Each numeric value in the file is an indication of the number of occurrences of each feature (e.g., forest, tree) multiplied by a given penalty. To generate instances from such a file, I use the following Java code:
String lineRegex = "^(S*)[s,]*(S*)[s,]*(.*)$";
String dataRegex = "[p{L}([0-9]*.[0-9]+|[0-9]+)_=]+";
InstanceList generateInstances(String dataPath) throws UnsupportedEncodingException, FileNotFoundException {
ArrayList<Pipe> pipeList = new ArrayList<Pipe>();
pipeList.add(new Target2Label());
[Code] .....
I then add the so-generated instances to my model using the instruction model.addInstances(generatedInstances). The resulting output is described below.
It contains errors caused by the instruction model.addInstances(generatedInstances). Debugging my code showed me that the alphabet associated to the model is null. Am I using the wrong iterator?
name: document1
target: label1
input: TokenSequence [forest=3.4 feature(forest)=3.4 span[0..10], tree=5 feature(tree)=5.0 span[11..17], wood=2.85 feature(wood)=2.85 span[18..27], hammer=1 feature(hammer)=1.0 span[28..36], colour=1 feature(colour)=1.0 span[37..45], leaf=1.5 feature(leaf)=1.5 span[46..54]]
Token#0:forest=3.4 feature(forest)=3.4 span[0..10]
[Code] ....
View Replies
View Related
Dec 11, 2014
The problem I'm having right now is invoking the get method in my main. I get a "cannot find symbol - variable deposit" error message. I also am at a loss as to what to do for the first two classes as well as the interest class. What I had for the first two didn't work, so I scrapped itand don't remember what it was.
Here's the code and error message:
import java.text.NumberFormat;
import java.util.Scanner;
public class BankAccount
{
private double balance;
private double name;
private int BankAccount;
[Code] .....
Attached image(s)
View Replies
View Related
Feb 13, 2015
I'm trying to change the code on a Fibonacci series program that would allow me to exit the loop early if I exceed a specified number. The user enters any 2 random numbers (which will be the 1st 2 no.'s of the Fibonacci sequence printed to screen) and then continues up to a 'limit' on the number of numbers set in code. Here's the code:
int[] array = new int[limit]; //Define an array whose length is set by an int value for limit!!
array[0] = x; //User supplies a int value for x which takes the 1st position in the array!!
array[1] = y; //...and an int value for y in the 2nd position!!
for (int i = 2; i < limit; i++) //Start from the 3rd position of the array when carrying out calculations!! {
array[i] = array[i-1] + array[i-2];
[Code] ....
To exit the code/ 'limit' early if the array prints a number higher than 100, I tried putting a 'while' condition before the last line, as follows:
while (array[i] < 100)
System.out.print(array[i] + " ");
Can I even use a 'while' loop within an array, or is there some other way I need to integrate it?
View Replies
View Related
Mar 10, 2014
I need to design 'notepad' application as my assignment.
Requirement: Only text is allowed, all the characters are having same size and font. It should have feature like new, open, save , save as , exit , UNDO , find , replace and font.
For this i use JTextArea and menu bar .
I am able to develop features like new, open, save , save as , exit. Need to implement now UNDO , find , replace and font but struck at 'UNDO'.
UNDO feature should be enable only when user writing in the writing area but not when it opens any file. What i thought is to have a flag on whenever user save whatever he wrote and if he use select UNDO then it check for the flag. If flag is ON then it will not do UNDO and if flag is not set then it cleared everything from the Text Area.
View Replies
View Related
Apr 21, 2015
I'm using json to submit form from web and mobile, I want to add uploading image feature to this form. How can I do that with code if possible?
View Replies
View Related
Feb 24, 2014
As of now am using icefaces 1.8.2 provided tags for downloading data into excel sheet where i can download all the data from a data table. But now the requirement is like need to download the data into excel sheet based on values passed from UI as parameters to the action class method.
Attaching the code snippet along with this post.
CustomerList.xhtml :-
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<ice:outputLabel value="Export:" />
[Code] ....
View Replies
View Related
Jun 14, 2014
The erasures of all constituent types of a bound must be pairwise different, or a compile-time error occurs.
Well I know what type erasure is, and I think I kind got what this statement means. My understanding from it is that if your type parameter has more than one bound and those bounds occurs to be the same type after erasure that is a compile-time error. Is that it?
The only thing I could found related is something like this:
class A<T extends List<Integer> & List<Integer>>{
}
Which as you might know gives the Duplicated bound error.
View Replies
View Related
Apr 22, 2014
I need to be able to detect IE 9, IE 10, IE 11 and the latest from Firefox and Chrome. The old method using the user-agent string is unreliable and not recommended. There is a different approach called, "Feature Detection". But I need to know what features to test to determine the browser. I can write it myself, or if there is a handy dandy API using feature detection already written that would be OK too.
View Replies
View Related
Mar 12, 2015
Opoly works this way: The board is a circular track of variable length (the user determines the length when the game app runs). There is only one player, who begins the game at position 0.
Thus, if the board length is 20, then the board locations start at position 0 and end at position 19. The player starts with a reward of 100, and the goal of the game is to reach or exceed reward value 1000. When this reward value is reached or exceeded, the game is over. When the game ends, your program should report the number of turns the player has taken, and the final reward amount attained.
In Opoly the game piece advances via a spinner - a device that takes on one of the values 1, 2, 3, 4, 5 at random, with each of the five spin values equally likely.
Although the board is circular, you should draw the state of the board as a single "line", using an 'o' to represent the current player position, and * represent all other positions. Thus if the board size is 10, then this board drawing:
**o******
means that the player is at location 2 on the board.
Here are the other Opoly game rules:
If your board piece lands on a board cell that is evenly divisible by 7, your reward doubles.
If you land on the final board cell, you must go back 3 spaces. Thus if the board size is 20, the last position is position 19, and if you land there, you should go back to position 16. (If the position of the last cell is evenly divisible by 7, no extra points are added, but if the new piece location, 3 places back, IS evenly divisible by 7, then extra points ARE added).
If you make it all the way around the board, you get 100 points. Note that if you land exactly on location 0, you first receive 100 extra points (for making it all the around), and then your score is doubled, since 0 is evenly divisible by 7,
Every tenth move (that is, every tenth spin of the spinner, move numbers 10,20,30,... etc.), reduces the reward by 50 points. This penalty is applied up front, as soon as the 10th or 20th or 30th move is made, even if other actions at that instant also apply. Notice that with this rule it's possible for the reward amount to become negative.
Here is the driver class for the game:
import java.util.*;
public class OpolyDriver{
public static void main(String[] args){
System.out.println("Enter an int > 3 - the size of the board");
Scanner s = new Scanner(System.in);
int boardSize = s.nextInt();
[Code] ....
heres the methods:
REQUIRED CODE STRUCTURE: Your Opoly class must include the following methods (in addition to the Opoly constructor) and must implement the method calls as specified:
playGame - The top-level method that controls the game. No return value, no parameters. Must call drawBoard, displayReport, spinAndMove, isGameOver.
spinAndMove - spins the spinner and then advances the piece according to the rules of the game. No return value, no parameters. Must call spin and move.
spin - generates an integer value from 1 to 5 at random- all equally likely. Returns an integer, no parameters.
move - advances the piece according to the rules of the game. No return value, takes an integer parameter that is a value from 1 to 5.
isGameOver - checks if game termination condition has been met. Returns true if game is over, false otherwise. No parameters.
drawBoard - draws the board using *'s and an o to mark the current board position. Following each board display you should also report the current reward. No return value, no parameters.
displayReport - reports the end of the game, and gives the number of rounds of play, and the final reward. No return value, no parameters.
View Replies
View Related
Oct 17, 2014
I want to know is there a limit for length of get url request? if if what is the max length.
View Replies
View Related
Oct 26, 2014
When I enter the wrong password, it says I have successfully logged in.
import javax.swing.JOptionPane;
public class P2H
{
public static void main (String[] args) {
System.out.println("LOGIN");
String usernameStr=JOptionPane.showInputDialog("Enter Username");
[Code] ....
Also I have to limit password attempts to 3. How would I go about that?
View Replies
View Related
Mar 2, 2015
I am trying to make a program in which first I am entering number of charachters and then in nextline their is exactly that number of characters should be enter after than program should stop taking input from console..this is I have try so far
private static ArrayList<String> chars;
static String inputdata;
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
chars=new ArrayList<String>();
[code]....
View Replies
View Related
Mar 3, 2014
When I add to a JScrollPane (I'm adding to a JPanel then putting that in the scroll pane) it displays as many items in one row as possible. How can I make it so that it only displays one per row?
View Replies
View Related
Feb 13, 2014
I need to set a limit when a textfield is typed, I don't know where to start to do this validate.
Any way to do it. or can you take me to the correct path.??
View Replies
View Related
Mar 22, 2014
What is limitation for command line parameter??
View Replies
View Related
Aug 31, 2014
I just started to learn Java. In my program, I created a GRect(paddle) and I would like to move it on the x axis whenever the mouse is moved.
import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.awt.*;
import java.awt.event.*;
public class BreakoutClass extends GraphicsProgram {
/** Width and height of application window in pixels */
private static final int WIDTH = 400;
private static final int HEIGHT = 600;
[code]....
In this case, whenever the paddle reaches the right edge of the screen, it doesn't move off the windows, but it stops moving (even if you move the mouse).
View Replies
View Related
Mar 31, 2014
I tried to Google, but was not able to find anything relevant.
I have a sql query where in I am using preparedStatement which goes something like :
select * from test where parameters in ( ?,?,?,?,?,?,?,?,?,?,?,?,?);
Is there a limit on how many "?" characters i.e. parameters can be there in this query?
View Replies
View Related
Apr 23, 2014
I am just not sure of some theory in collections, ArrayList and LinkedList maximum capacity depends on the memory allocated to the JVM. But according to few people those list has a maximum capacity of Integer.MAX_VALUE.
According to my experiment, those list has a maximum capacity of Integer.MAX_VALUE since the get method of List accept a parameter of int primitive type (index of element), therefore we can conclude that the maximum capacity of List is equal to Integer.MAX_VALUE.
But what about the Map? get() method of map accepts object(the key of the map). So does it mean that the maximum capacity of Map depends on the memory allocated to our JVM? Or its maximum size is Integer.MAX_VALUE also just like Lists and Arrays? Is there a way to prove it? Is Map designed to hold infinite number of data (disregarding the heap memory space exception)?
And also about Stack, Deque? is it also the same as Map (in terms of maximum capacity)?
View Replies
View Related
Nov 21, 2014
i need to calculate the minimum and the maximum, actually it seems to be easy but, the minimum should be the smallest number but 0..this is my code
Java Code:
Scanner s = new Scanner (System.in);
int max = 0 ;
int min = 0 ;
System.out.println(" Please enter 3-5 numbers");
int a = s.nextInt();
int b = s.nextInt();
int c = s.nextInt();
int d = s.nextInt();
int e = s.nextInt();
[code]....
View Replies
View Related
Feb 20, 2015
I am doing a homework assignment for a class I'm taking and writing a java program that finds the smallest and largest number in an array entered by the user. For some reason no matter what I enter as the smallest number it returns 0 as the smallest. I'm not sure what I have done wrong. Here is my code:
import javax.swing.JOptionPane;
public class MinimumAndMaximumJamesBulow
{
public static void main(String[] args)
{
int minimum = 0;
int maximum = 0;
[Code] ....
View Replies
View Related
Feb 8, 2014
I want to limit the program to only accept a 12 digit input and an integer value but I don't know how to program it,
import java.util.Scanner;
public class testing4
{
public static void main(String []args) {
Scanner reader = new Scanner(System.in);
String input;
[Code]...
View Replies
View Related