Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.applet.*;
- import java.awt.event.*;
- public class rhullfin1 extends Applet implements ItemListener
- {
- //Ceate components for applet
- Label CompanyLabel=new Label("Imus Computer College");
- Label paymentLabel=new Label("Please enter the Tuition Fee");
- TextField paymentField=new TextField(20);
- Label optionLabel=new Label("Please choose your Payment Scheme");
- CheckboxGroup paymentGroup=new CheckboxGroup();
- Checkbox cashBox=new Checkbox("Cash Payment",false,paymentGroup);
- Checkbox installmentBox=new Checkbox("Installment",false,paymentGroup);
- Label outputLabel=new Label("ICC assessment sample ");
- public void init()
- {
- //add Components to window and colors
- setBackground(Color.cyan);
- add(CompanyLabel);
- add(paymentLabel);
- add(paymentField);
- paymentfield.requestFocus();
- add(optionLabel);
- add(cashBox);
- cashBox.addItemListener(this);
- add(installmentBox);
- installmentBox.addItemListener(this);
- add(outputLabel);
- }
- public void itemStateChanged(ItemEvent choice)
- {
- try
- {
- double payment=0;
- double price=0;
- price=Double.parseDouble(paymentField.getText());
- if(price<=) throw new NumberFormatException();
- //check to see selected options
- if(cashBox.getState())
- {
- payment=price;
- outputLabel.setForeground(Color.black);
- outputLabel.setText("Your total Tuition Fee is Php"+payment);
- }
- else
- {
- //if(installmentbox.getState())
- payment=price*.05+price;
- outputLabel.setForeground(Color.black);
- outputLabel.setText("Your total Tuition Fee is Php"+payment);
- }
- }
- catch(NumberFormatException e)
- {
- outputLabel.setText("You must enter a valid Tuition Fee");
- outputLabel.setForeground(Color.red);
- paymentField.setText("");
- paymentField.requestFocus();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement