Tel Tel Mobile Company Informatics Practices 2017

Ms Fauzia works as a programmer in “TelTel Mobile Company” where she has designed a software to compute charges to be paid by the mobile phone user. A screenshot of the same is shown below:

Each call is charged at Rs. 1.00.
Each SMS is charged at Rs. 0.50.

Users can also opt for Mobile Data Plan. Charges for Mobile Data Plan are flat Rs. 50.0.

Help Ms Fauzia in writing the code to do the following:

  • When the ‘Calculate Charges’ button is clicked, ‘Calls and SMS Charges’, ‘Mobile Data Plan Charges’ and ‘Amount to Pay’ should be calculated and displayed in the respective text fields.
  • When the ‘Clear’ button is clicked, all the text fields and checkbox should be cleared.
  • When the ‘Exit’ button is clicked, the application should close.
private void buttonChargesActionPerformed(java.awt.event.ActionEvent evt) {
    double callCharges = 0.0;
    double dataCharges = 0.0;
    double amount = 0.0;
    int calls = Integer.parseInt(textFieldCalls.getText());
    int sms = Integer.parseInt(textFieldSMS.getText());
    callCharges = calls + sms * 0.5;
    if(checkDataPlan.isSelected())
        dataCharges = 50.0;
    amount = callCharges + dataCharges;
    textFieldCallCharges.setText(Double.toString(callCharges));
    textFieldDataCharges.setText(Double.toString(dataCharges));
    textFieldAmount.setText(Double.toString(amount));
}

private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {
    textFieldName.setText("");
    textFieldPhone.setText("");
    textFieldCalls.setText("");
    textFieldSMS.setText("");
    checkDataPlan.setSelected(false);
    textFieldCallCharges.setText("");
    textFieldDataCharges.setText("");
    textFieldAmount.setText("");
}

private void buttonExitActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);
}

Leave a Reply

%d bloggers like this: