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 4 of 4

Thread: vending machine submit button help

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post vending machine submit button help

    Hi ,
    I have created a submit button "sbutton" that should take all totals from 3 boxes and if that total is greater than 1, then it should be subtracted from 1 and the remainder is suppose to be displayed as change...this is what i have
    public void actionPerformed(ActionEvent evt) {
    if(evt.getSource()==sButton){
    change.setText(---"I DON"T KNOW WHAT TO PUT HERE")
    selections.setText("Vending....");

    and in another class to add up the 3 totals i have
    public String total5(){
    	total5=total+total2+total3+total4;
     
    	String blank =new String();
    	blank="$"+total5;
    		return blank;
     
     
     
    }

    so my question is how do i use the total5 to compare if it's over 1 or less and display if it's over in the "change.setText( )" text box?


  2. #2
    Junior Member
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: vending machine submit button help

    How did method total5() is implemented on the actionPerformed method?

  3. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: vending machine submit button help

    Also note that this kind of coding is NEVER required;
    	String blank =new String();
    	blank="$"+total5;
    		return blank;
    That should be
    	return "$"+total5;
    db

  4. #4
    Junior Member
    Join Date
    Apr 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up Re: vending machine submit button help

    thanks, i figured it out.

Similar Threads

  1. Moving MySql Database from one machine to another machine
    By vaishali in forum JDBC & Databases
    Replies: 5
    Last Post: July 21st, 2010, 01:21 AM
  2. help with my machine project.
    By Irvine in forum AWT / Java Swing
    Replies: 4
    Last Post: September 1st, 2009, 05:13 AM
  3. need help with Vending Machine code...
    By mia_tech in forum Loops & Control Statements
    Replies: 3
    Last Post: April 20th, 2009, 05:24 AM
  4. Replies: 8
    Last Post: February 24th, 2009, 04:04 PM
  5. Replies: 6
    Last Post: November 14th, 2008, 03:09 PM