PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

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

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

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

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


Leave a Reply