You require an algorithm to read in one customer's account balance at the begining of the month, a total of all withdrawals for the month, and a total of all deposits made during the month. A federal tax charge of 1% is applied to all transactions made during the month. The program is to calculate the account balance at end of the month by (1) subtracting the total withdrawals from the account balance at the beginning of the month, (2) adding the total deposits to new balance, (3) calculating the federal tax (1% of total transactions - that is, total withdrawals+total deposits), and (4) subtracting this federal tax from the new balance. After these calculations, print the final end-of-month balance.
This happens to be the homework problem on www.palinfonet.com/hw_java2008.pdf due April 17th 2008, question #3.
This will be a straightforward translation into pseudocode. As this is a homework assignment¸ you'll have to do the legwork yourself. Just evaluate each step in turn:
input: accountBalanceStart, totalDeposits, totalWithdrawals
output: accountBalanceEnd
Let's take the first step:
accountBalanceEnd <-- accountBalanceStart - totalWithdrawals
Now the second:
accountBalanceEnd <-- accountBalanceEnd + totalDeposits
Next, compute the tax and subtract it:
accountBalanceEnd <-- accountBalanceEnd - (totalWithdrawals + totalDeposits) * 0.01
Finally, show the result:
print accountBalanceEnd
I agree with the other posters, that this is neither a question nor is this a place where people are going to do your homework. But just in case you really absolutely have no clue I give a more concrete example.
What you most likely will need to read:
I would probably try something like this. I intendedly haven't tested or commented it and the syntax might also be wrong for mssql.
CREATE OR REPLACE FUNCTION Calculate_Balance(account_id long, account_balance float, date datetime) RETURNS float AS
DECLARE
transactions_sum float;
fed_tax float;
new_account_balance float;
BEGIN
transactions_sum = SELECT SUM(amount) from transactions
WHERE transactions.account_id = account_id
AND month(transactions.date) = month(date)
AND year(transactions.date) = year(date);
fed_tax = transactions_sum * 0,01;
transactions_sum = transactions_sum - fed_tax;
new_account_balance = transactions_sum + account_balance;
RETURN new_account_balance;
END;