|
You last visited: Today at 19:33
Advertisement
Hybrids Coding Guide #4
Discussion on Hybrids Coding Guide #4 within the CO2 Programming forum part of the Conquer Online 2 category.
07/30/2012, 03:40
|
#1
|
elite*gold: 0
Join Date: Nov 2010
Posts: 41
Received Thanks: 17
|
Hybrids Coding Guide #4
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
|
#2
|
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
|
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
|
#3
|
elite*gold: 0
Join Date: Nov 2010
Posts: 41
Received Thanks: 17
|
Quote:
Originally Posted by _tao4229_
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 *****, 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
|
#4
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
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
|
#5
|
elite*gold: 0
Join Date: Nov 2010
Posts: 41
Received Thanks: 17
|
Quote:
Originally Posted by _tao4229_
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
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.
|
|
|
Similar Threads
|
[Guide] - Coding a GW Bot
05/08/2022 - GW Guides & Templates - 98 Replies
Coding a GW Bot
featuring the tt6
In diesem Guide werde ich euch mein Wissen in Thema Bot-Coding vermitteln. Vom GUI bis zum vollendeten Bot, werde ich alles detailliert beschreiben. Das ganze wird an einem Beispiel-Bot erklärt, dem Sanctum Cay Bot.
Inhaltsverzeichnis
1. Programme
2. Vorbereitung
|
All times are GMT +1. The time now is 19:35.
|
|