Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Dissagreement with teacher

Author  Topic 

WorldFamousBigB
Starting Member

5 Posts

Posted - 2009-11-03 : 15:28:07
Hello folks, I'm new to SQL; I'm taking a college course in programming right now. On a recent multiple choice test I got an answer wrong, but I believe I actually got it right. I think there were accidentally two correct answers. What does everyone else think? Here's the question:

Which of the following expressions will not compute 10% of the balance due if balance due is the invoice total minus the credit total minus the payment total?

a. InvoiceTotal - CreditTotal - PaymentTotal / 10
b. (InvoiceTotal - PaymentTotal - CreditTotal) / 10
c. (InvoiceTotal - (PaymentTotal - CreditTotal)) * 0.10
d. ((InvoiceTotal - PaymentTotal) - CreditTotal) / 10

My answer was C. I've got a math background, so I picked up on the negative signs inside and outside of the brackets right away. I didn't look too closely at A, which was given as the correct answer, but it obviously won't return the desired result. I think it was just a small error on the part of the person making up the test. What do you think? Could B, C and D all be considered to fit within the parameters of computing 10% of the invoice total minus the credit total minus the payment total?

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-03 : 15:37:20
I don't to get it


DECLARE @InvoiceTotal money, @CreditTotal money, @PaymentTotal money
SELECT @InvoiceTotal = 100, @CreditTotal = 50, @PaymentTotal = 25

SELECT
@InvoiceTotal - @CreditTotal - @PaymentTotal / 10 AS A
, ( @InvoiceTotal - @PaymentTotal - @CreditTotal) / 10 AS B
, ( @InvoiceTotal - (@PaymentTotal - @CreditTotal)) * 0.10 AS C
, ((@InvoiceTotal - @PaymentTotal) - @CreditTotal) / 10 AS D



Returns


A B C D
--------------------- --------------------- --------------------------------------- ---------------------
47.50 2.50 12.500000 2.50

(1 row(s) affected)




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-03 : 15:38:03
What is the course in?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-11-03 : 15:40:42
Looks like a simple query shows that A and C are correct responses:
DECLARE @T TABLE (InvoiceTotal MONEY, CreditTotal MONEY, PaymentTotal MONEY)

INSERT @T
SELECT $10000.00, $500.00, $4000.00
UNION ALL SELECT $8765.86, $33.35, $1876.00


SELECT
InvoiceTotal - CreditTotal - PaymentTotal / 10
,(InvoiceTotal - PaymentTotal - CreditTotal) / 10
,(InvoiceTotal - (PaymentTotal - CreditTotal)) * 0.10
,((InvoiceTotal - PaymentTotal) - CreditTotal) / 10
FROM @T AS T
Doh, to slow! :)
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-03 : 15:44:05
What actually is that formula suppose to be determining?

A is dividing the payment by 10

I don't think I want ANY of my payments being divided by 10

Beer would cost 400/night



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2009-11-03 : 15:55:37
A simple test makes it fairly obvious that answers A and C both produce wrong answers.

I don’t understand why you didn't just test it yourself and demonstrate this to the teacher, instead of posting the question here.




CODO ERGO SUM
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2009-11-04 : 10:54:04
Both A and C yield incorrect answers.
And this is basic 6th grade math. Not SQL.
________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page
   

- Advertisement -