954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Vending Machine Submit button help please

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?

bondgirl21
Light Poster
41 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

don't try to do that with strings.
Check whether the actual amount (number!) is >1.0 instead, much easier.

And btw, you add 4 amounts there, not 3 :)

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

don't try to do that with strings. Check whether the actual amount (number!) is >1.0 instead, much easier.

And btw, you add 4 amounts there, not 3 :)


thanks, i figured it out.

bondgirl21
Light Poster
41 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: