Photo AI

The MidCity Shopping Centre sells gift vouchers that can be used at any shop in the shopping centre - NSC Information Technology - Question 3 - 2021 - Paper 1

Question icon

Question 3

The-MidCity-Shopping-Centre-sells-gift-vouchers-that-can-be-used-at-any-shop-in-the-shopping-centre-NSC Information Technology-Question 3-2021-Paper 1.png

The MidCity Shopping Centre sells gift vouchers that can be used at any shop in the shopping centre. The minimum amount available per gift voucher card is R50 and th... show full transcript

Worked Solution & Example Answer:The MidCity Shopping Centre sells gift vouchers that can be used at any shop in the shopping centre - NSC Information Technology - Question 3 - 2021 - Paper 1

Step 1

3.1 - Purchase gift voucher

96%

114 rated

Answer

  1. Extract the gift voucher number from the component edt03_VoucherNum.
  2. Extract the name of the customer from the component edt03_2_1.
  3. Extract the amount from the component cmb03_2_1.
  4. Instantiate a new objGiftVoucher object using the extracted values:
    objGiftVoucher = new GiftVoucher(voucherNumber, customerName, amount);
    
  5. Display the details of the gift voucher using toString method in the output area red03_2_1:
    red03_2_1.setText(objGiftVoucher.toString());
    

Step 2

3.2.2 - Button [Display balance]

99%

104 rated

Answer

  1. Retrieve the gift voucher number from edt03_VoucherNum.

  2. Check if the gift voucher number matches the existing voucher's number:

    if (objGiftVoucher.getVoucherNumber() == enteredVoucherNum) {
    
  3. Use the getBalance method to retrieve and display the balance in panel pnl03_2_2:

    double balance = objGiftVoucher.getBalance();
    pnl03_2_2.setText(String.format("Balance: %.2f", balance));
    
  4. Enable the button btn03_2_2_b for further actions.

  5. Button [Use gift voucher]:

    1. Extract the purchase amount from the edit box and convert it to the appropriate data type.
    2. Check if the voucher is sufficient using:
      if (objGiftVoucher.isSufficient(purchaseAmount)) {
      
    3. If sufficient, call updateBalance(purchaseAmount) and display success message:
      objGiftVoucher.updateBalance(purchaseAmount);
      lblMessage.setText("Voucher successfully used");
      
    4. If insufficient, calculate and display the outstanding amount and show a message accordingly.

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;