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?

Recommended Answers

All 2 Replies

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 :)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.