C
C#3mo ago
Crunchy

✅ if statement help

help
No description
19 Replies
Crunchy
Crunchy3mo ago
Im making it wher i cant use negitives im new so any help would be nice
blueberriesiftheywerecats
what is the value of Program.balance
Crunchy
Crunchy3mo ago
1000
blueberriesiftheywerecats
and what happen when you substract -1000 from 1000 like 1000 - (-1000)?
Crunchy
Crunchy3mo ago
PasteCode
test5555 - PasteCode.dev
PasteCode.dev is a website where you can store any code online for quick sharing. You can paste code and share code online for free.
blueberriesiftheywerecats
what is the value of 1000 - (-1000)?
Crunchy
Crunchy3mo ago
No description
Crunchy
Crunchy3mo ago
this?
blueberriesiftheywerecats
i mean just solve simple math question and you will understand, what is 1000 - (-1000)
Crunchy
Crunchy3mo ago
2000
blueberriesiftheywerecats
yes, which means that NewBalance now has a value of 2000 and when you check if 2000 <= 0 it will be false if I understood what you want to accomplish you should change if(NewBalance <= 0) to if(withDrawl_Ammount <= 0)
Crunchy
Crunchy3mo ago
omg im dumb sorry im now understanding i got another Q for u
Crunchy
Crunchy3mo ago
what am i doing wrong here for math
No description
Crunchy
Crunchy3mo ago
cause i need it to add to my orignal balence
Kouhai
Kouhai3mo ago
You're returning from the method on this line which causes the rest of the method to never get executed
No description
Kouhai
Kouhai3mo ago
Besides that, you're not check if depositAmount is negative or not You're only checking if adding the deposit amount with the Program.balance causes Program.balance to be lower than or equal to zero So if your Program.balance is 1000 and your depositAmount is -10 Program.balance is 990
Crunchy
Crunchy3mo ago
soo just remove the = in <= ? also how do i make it add still the Program.balence still says 1000 im bad at math oh nvm i needed to swap program.balence abd newBalenceDepo var
Pobiega
Pobiega3mo ago
if (trueOrFalse)
{
// everything inside the brackets is conditional
}

if(trueOrFalse)
Console.WriteLine("This is conditional.");
Console.WriteLine("This ALWAYS happens.");
if (trueOrFalse)
{
// everything inside the brackets is conditional
}

if(trueOrFalse)
Console.WriteLine("This is conditional.");
Console.WriteLine("This ALWAYS happens.");
this isnt python - if you skip the braces after an if (...) only the next statement is conditional so that return; Kouhai pointed out isnt conditional - it always runs
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server