Hybrids Coding Guide #4

07/30/2012 03:40 ThoughtZProductionS#1
So i was looking at hybrids tutorials to learn C# and i came across this assignment he wanted us to do and i wasnt going to skip it just because no one will know i skipped it, and i didnt want to cheat myself, so he gave me this "Problem" and i had to answer it in C#. i think i did it right, but im really not sure. so can someone take a look at it for me? if you dont know how to code, dont post in this thread, im looking for some real help and not some smartass answers, so thanks in advance to whoever helps me.

Problem:
Angelica has a bank account. Each month, she gains an interest of 0.03%. There withdrawal fee of $1.00 (every time money is withdrawn from the account $1.00 is also subtracted). Today, Angelica withdraws $20, but what will her balance be next month? Angelica will input her balance into your program.


What i have in C#:
Code:
[COLOR="#3300cc"]namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double balance = double.Parse(Console.ReadLine());
            balance = balance + (balance * 0.03);
            balance = balance - (20 - 1);
            Console.WriteLine(balance); // First month
            balance = balance + (balance * 0.03);
            Console.WriteLine(balance); // Second Month
        }
    }
}[/COLOR]
07/30/2012 08:47 _tao4229_#2
From the problem it seems like there's only one months worth of interest. Just a reading difference (I could be wrong). And technically if its 0.03% then it's actually 1.00003 x the balance. Another reading difference. And the way order of operations works you need to take out the parenthesis in balance - (20 - 1), because that's actually balance - 19 (it subtracts 1 from 20 first, leaving 19), when you really want balance - 21.
07/30/2012 09:25 ThoughtZProductionS#3
Quote:
Originally Posted by _tao4229_ View Post
From the problem it seems like there's only one months worth of interest. Just a reading difference (I could be wrong). And technically if its 0.03% then it's actually 1.00003 x the balance. Another reading difference. And the way order of operations works you need to take out the parenthesis in balance - (20 - 1), because that's actually balance - 19 (it subtracts 1 from 20 first, leaving 19), when you really want balance - 21.

i have no clue lmfao, im trying to teach myselff, its extremely hard specially at my age, and your right if those calculations were true, but an error you just point at to me is "balance = balance - (20 +- 1)" because your withdrawing 20 bucks but the bank is then taking 1 dollar out of your bank account, the way i had it written was what you said, you would be withdrawing 19 bucks, and i dont know what to tell ya about the months thing, im on Lession number 8 and im barely getting the hang of each lesson, but w/e hopefully ill run into someone who wants to help xD.
07/30/2012 10:00 Korvacs#4
The way you had it written you were removing $19 from the account. You should be removing $21 from the account, nevermind if its being withdrawn or otherwise. Do it in 2 separate modifications to the balance if your struggling to understand this:

Say you have $100 and you withdraw $20, 100 - 20 = 80. Then the bank charges you $1 for the withdrawal 80 - 1 = 79. 100 - 79 = 21.

The amount you withdraw doesn't just decrease by $1, that's not how banks operate.
07/30/2012 10:34 ThoughtZProductionS#5
Quote:
Originally Posted by _tao4229_ View Post
From the problem it seems like there's only one months worth of interest. Just a reading difference (I could be wrong). And technically if its 0.03% then it's actually 1.00003 x the balance. Another reading difference. And the way order of operations works you need to take out the parenthesis in balance - (20 - 1), because that's actually balance - 19 (it subtracts 1 from 20 first, leaving 19), when you really want balance - 21.
Quote:
Originally Posted by Korvacs View Post
The way you had it written you were removing $19 from the account. You should be removing $21 from the account, nevermind if its being withdrawn or otherwise. Do it in 2 separate modifications to the balance if your struggling to understand this:

Say you have $100 and you withdraw $20, 100 - 20 = 80. Then the bank charges you $1 for the withdrawal 80 - 1 = 79. 100 - 79 = 21.

The amount you withdraw doesn't just decrease by $1, that's not how banks operate.
i know, i didnt mean to put (20 - 1) that lost post should have said that if im not mistaken? but thanks bro.