Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How to build an array and use it to check a calculation

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to build an array and use it to check a calculation

    I want to build an Array[] with the numbers 1-100;

    After the program turns the String inputAmount ,into a double input, I'm going to divide input by 20 = withdrawIncrement.
    How do I check withdrawIncrement through the Array[] to find a match

    private class BtnHandler implements ActionListener {
     
    		public void actionPerformed(ActionEvent event) {
     
    			exit = "";
     
    			while(accountBoolean == true && exit != null) {
     
    			    if(event.getSource() == btnWithdraw) {
    			    	transCount++;
    				    String inputAmount = JOptionPane.showInputDialog("Enter amount to withdraw from Savings");
    				    double input = Double.parseDouble(inputAmount);
     
    	/////////THIS IS WHERE I WANT TO CHECK TO MAKE SURE WITHDRAWINCREMENT IS IN ARRAY[]/////////////////////    
     
                                        savingsBalance = savingsBalance - input;
    				    if(savingsBalance > 0) {
    				        if(transCount <= 4) {
    				    	    JOptionPane.showMessageDialog(null, "Savings account balance after withdraw: " + savingsBalance, 
    				    		                              "Withdraw Window", JOptionPane.PLAIN_MESSAGE);

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,407
    Thanks
    53
    Thanked 2,399 Times in 2,352 Posts

    Default Re: How to build an array and use it to check a calculation

    MAKE SURE WITHDRAWINCREMENT IS IN ARRAY
    One way would to use a loop that examines all the elements in the array.
    If the array is in order, the Arrays class has a search method to search for a match.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: July 26th, 2014, 04:38 AM
  2. Replies: 3
    Last Post: December 13th, 2013, 12:19 PM
  3. Difference between Maven Build and Eclipse Build
    By Beginner2java in forum Java IDEs
    Replies: 2
    Last Post: October 14th, 2013, 10:13 AM
  4. Difference between Maven Build and Eclipse Build
    By Beginner2java in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 14th, 2013, 10:09 AM
  5. Java array calculation
    By maple1100 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 1st, 2013, 01:05 PM