Which code segment should you insert?

You create Web-based applications. You are creating an Internet banking application. The application will be used by bank account holders.

You are creating a method to withdraw money from an account. The method must change the account balance according to one of the following rules:

If the amount that is being withdrawn is less than or equal to the account balance, then subtract the amount from the balance.
If the amount that is being withdrawn is greater than the account balance by up to 500 dollars, then subtract the amount and a 35-dollar fee from the balance.
If the amount that is being withdrawn is greater than the account balance by more than 500 dollars, then generate an error.
You are translating the specification given here into pseudo code. You start by writing the following code.

Method
public void Withdraw
Input parameters
decimal amount
Class field
decimal balance
Pseudo code
//your pseudo code

You need to insert the correct pseudo code. Which code segment should you insert?

You create Web-based applications. You are creating an Internet banking application. The application will be used by bank account holders.

You are creating a method to withdraw money from an account. The method must change the account balance according to one of the following rules:

If the amount that is being withdrawn is less than or equal to the account balance, then subtract the amount from the balance.
If the amount that is being withdrawn is greater than the account balance by up to 500 dollars, then subtract the amount and a 35-dollar fee from the balance.
If the amount that is being withdrawn is greater than the account balance by more than 500 dollars, then generate an error.
You are translating the specification given here into pseudo code. You start by writing the following code.

Method
public void Withdraw
Input parameters
decimal amount
Class field
decimal balance
Pseudo code
//your pseudo code

You need to insert the correct pseudo code. Which code segment should you insert?

A.
If amount < balance then balance – = amountIf amount < balance + 500 then balance = balance – (amount + 35) If amount > balance + 500 then throw exception

B.
If amount <= balance then balance – = amountIf amount <= balance + 500 then balance = balance – (amount + 35) If amount > balance + 500 then throw exception

C.
If amount < balance then balance – = amountElse If amount < balance + 500 then balance = balance – (amount + 35) Else throw exception

D.
If amount <= balance then balance – = amountElse If amount <= balance + 500 then balance = balance – (amount + 35) Else throw exception



Leave a Reply 0

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