|
|
|
<< Back public void actionPerformed(ActionEvent e) { int[] guestLimit = {1,25,50,100,200,500,1000}; int[] ratePerGuest = {27,25,22,19,17,14,11}; int guests = Integer.parseInt(numGuests.getText()); int individualFee = 0, eventFee = 0; int x=0, a=0; for(x=6; x>=0; --x) { if (guests >= guestLimit[x]) { individualFee = ratePerGuest[x]; eventFee = guests * individualFee; x = 0; } } perPersonResult.setText("$" + individualFee + " per person"); totalResult.setText("Event cost $" + eventFee); } |