Java Netbeans program in which ABN Shipment Corporation imposes charges on Wholesaler and Retailers.

Q21. ABN Shipment Corporation imposes charges to customers for different products. The shipment company costs for an order in two forms: Wholesalers and Retailers. The cost is calculated on unit basis as follows:

For Units Price for Wholesaler

(per unit)

Price for Retailers

(per unit)

1-15 Rs 50/- Rs 60/-
16-20 Rs 45/- Rs 55/-
21-30 Rs 40/- Rs 50/-
31-50 Rs 35/- Rs 45/-
>50 Rs 30/- Rs 40/-

 

Special customer (named as chkSpecial JCheckBox Control) are given a discount of 10 %. The Following is the screen used to calculate Net Amount for an order:

A JLabel contains customer type as Wholesalers and Retailers as opteWhole and optRetail jRadioButton. User will enter the Units Order(txtUnit). Discount named as txtDisc JTextField.

  1. Write the code to disable the text boxes txtTotal and txtDisc and Wholesaler as default option when the form is active.
  2. Write the code for Calculate Amount Button to
  3. Display the discounted price in txtDisc if Special customer is selected.
  4. Display Net Amount.(Total cost=order unit * per unit price)
  5. Write the code for clear and Exit Button to
  6. Clear all Text Field and select wholesaler as default and uncheck special customer if is it.   

 

 

Solution:

Code for Load Screen (Right Click On Frame then>> Event then>> on left window then>> window opens) :

private void formWindowOpened(java.awt.event.WindowEvent evt) {

// TODO add your handling code here:

txtDisc.setEnabled(false);

txtTotal.setEnabled(false);

optWhole.setSelected(true);

}

 

Code for Calculate Amount Button:

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

int unit=Integer.parseInt(txtUnit.getText());

double price,cost,disc=0,total;

if(optWhole.isSelected())

{

if(unit<=15)

price=50;

else if(unit<=20)

price=45;

else if(unit<=30)

price=40;

else if(unit<=50)

price=35;

else

price=30;

}

else

{

if(unit<=15)

price=60;

else if(unit<=20)

price=55;

else if(unit<=30)

price=50;

else if(unit<=50)

price=45;

else

price=40;

}

cost=unit*price;

if(chkSpecial.isSelected())

disc=cost*10/100;

txtDisc.setText(Double.toString(disc));

total=cost-disc;

txtTotal.setText(Double.toString(total));

}

 

Code for Clear Button:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

txtUnit.setText(“”);

txtDisc.setText(“”);

txtTotal.setText(“”);

optWhole.setSelected(true);

chkSpecial.setSelected(false);

}

Code for Exit Button:

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

System.exit(0);

}

Output:

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

152 Views
%d bloggers like this: