Bank code
https://paste.mod.gg/jkuiernhqqgp/0
How can I use a while loop here?
BlazeBin - jkuiernhqqgp
A tool for sharing your source code with the world!
100 Replies
not sure if you're trolling or legitimate asking a question with your code indented like that sorry
can you resubmit the file so its readable at least?
CTRL+K+D if you're using visual studio to format your code
yeah that formatting is wild
I'm on mobile, I just started coding yesterday..
fair then if u would format the file and reupload that would be helpful for us to help you
Yeah sure one sec
https://pastebin.com/7DtqT9Y4
That works?
Pastebin
using System;class Bank{ static void Main() { Console....
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
yeah
it looks like you've already written a couple while loops. could you clarify what you're asking?
I basically want to start the questions again
In the top top
And the same proccess
In that case, you'd want all the logic of asking the questions and getting answers to be in the body of a while loop
much better yes! thanks
Yea but how
And I want the loop to be looped
Until the user says enough
Let's start with that. How are you determining when the user says enough?
put the logic in a while loop
I'd put a console.readline string in a and just , isn't that how it works?
Oops
you already ask the user for yes or no. like while(choice == "yes"){....}
Why's it like that
well right now you're using the
choice
variable, right? you read a string into that variable and check if it's one of a few possible responsesYeah I put the while there but I don't know what to loop here
Where to start and end
in this case, you always want to ask the questions at least once, so you're actually going to want a do while loop instead of a while loop
A while loop doesn't work? I only understand while loops
a do/while is very similar
it just always runs at least once
e.g.
What if I want more than once, also what does while false represent, what if I put true
what's inside the parentheses is the condition for the while loop: what determines if it'll run again
i just used
false
as an example
both will run as long as the condition is true
it's just that while
checks the condition before running the first time, and do/while doesn't
so with do/while, the code inside always runs at least once
whereas with while, it may not run at allSo if I put true it will run forever
yep
Ok now that I uh
Where do I start the loop what marks the end
The while ()?
this one?
No I want to loop the whole code over and over again until a break happens
The "do" marks the beginning of the loop and "while()" marks the end?
correct
but you'll need some code before
do
specifically you'll need to declare the variable that holds the user's answerString choice;
?
yep, but use lowercase
string
And where do I put the value
not a functional difference, it's just conventional C#
before the loop, should
choice
even have a value?choice is a readline
it's a variable
you're assigning the output of
Console.ReadLine().ToLower()
to itYes
but it's just a variable. it can remain uninitialized
so before the loop, should it have a value?
No
right
When I declare the thing assigned
It should be at that time when I ask if the user wants to continue doing actions
Am I correct
yep
So I would uhh
Put it in line 74 whatever
so your code will look like
Goes true
Also uhh
do you want it to keep going forever?
What if I want the loop to be in a if
Until the user commands it to stop
Line 73
so we definitely don't want
true
in the parentheses, otherwise it'll just keep going foreverBut false makes it go only once right?
there are infinitely many options other than
true
and false
Or do u mean once every run
you've got the logic there already,
if (choice == "yes" || choice == "yes.")
Or once every time the user wants to keep going
so
choice == "yes" || choice == "yes."
is what goes in the parentheses of the do/whileOk I'm dumb
that's a regular feeling in this line of work
Ok now time to do it
How did the do command work
Do{}
?
@mg
Iteration statements -for, foreach, do, and while - C# reference
C# iteration statements (for, foreach, do, and while) repeatedly execute a block of code. You use those statements to create loops or iterate through a collection.
Oh I put the while outside the do
Why is it giving me this error?

if u read the error it tells u what is missing there

I filled the errors and it gave me more errors 🥲
im not sure what filled means can u provide code?
if you look at the link above, a do while is written like this
you need to close it with the semicolon
I filled a } before a ;
So it became like
;}
On another error
I messed up something
can you show the code?
I CANT FIND IT
Pastebin
using System;class Bank{ static void Main() { string -...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
In most cases this will be an error
;}
I guess the problem is around here?
by adding a ; after the () in the while u essentially terminated the while
then u have broken brackets
}{}
its important that every time u open a bracket u know there is a pairing bracket for it
AKA
Yeah
It looks so wrong
yes, its what u have in your code.
On second
I would forget about the "Please say yes or no" part for now
What the hell is that bracket doing
you probably accidently added it once u broke the while
just focus on getting the do/while working and you can re-add that part later
so you need to fix it by removing the ;
and fixing the brackets

I FIXED IT
YES
the brackets were not positioned well
understanding your own code is 10 steps fowards 🙂
if you're using visual studio
you can also hover your mouse over the bracket
and it shows u what is its other side of the bracket
Yep
so u know they are opening and ending at the right place
Im using c# shell
Mobile app
Ok now something went wrong
No errors though
dawg the app stop wroking

Writing code on mobile has to be an... experience
I don't have a pc vruh
Remove the space a
before the semi-colon
while (choice != "yes" && choice != "yes." && choice != "no" && choice != "no.") ;
Alright
I can recommend getting a cheap Bluetooth keyboard if your phone supports it. That's how I did my statistics exam in R in college, since I didn't have a laptop :KEKW:
I actually used while commands before without semicolons and they worked well..
LOL
while
loops don't need a semicolon at the end, but do/whiles doOk my dumb ahh went straight to put semicolons after whiles
Generally, every control flow statement (
if
, for
, foreach
, while
, switch
, (arguably using
as well)) is structured like so:
One exception being do..while
CHAT
MY CODE IS DONE
IT WORKS
🎉
Pastebin
using System;class Bank{ static void Main() { string -...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
RAHHHHHHHHHHHTR
It's the hardest code I did so far
Thanks to all who helped
Appreciated fr
They say don't celebrate too early chat
Now -600+1000 is 400 but

yes
-600 + 1000 is indeed 400, so your program must not be computing -600 + 1000. it must be computing something else
not sure if whatever mobile IDE you're using supports breakpoints but at worst you can
Console.WriteLine()
to see what the value of different things are at different points in your code's execution