Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C# Password System with internal bank account which you can withdraw money from! (C#)

[CODE lang="csharp" title="Code - C#"]using System;


namespace Password_Bank_Code_

{

class Program

{

static void Main(string[] args)

{

//Bank Vault Password!

Console.ForegroundColor = ConsoleColor.White;

Console.BackgroundColor = ConsoleColor.Black;

string UserPassword = " ";

string password = "pass";


if (password == UserPassword)

{



if (password == UserPassword)

{

Console.WriteLine("Access Granted! ");

Console.WriteLine("Current Money Balance : 450");

Console.WriteLine("Would you like to withdraw some money? Y or N.");

if (password == UserPassword)

{

Console.WriteLine("Access Granted! ");

Console.WriteLine("Current Money Balance : 450");

Console.WriteLine("Would you like to withdraw some money? Y or N.");

if (password == UserPassword)

{

Console.WriteLine("Access Granted! ");

}

else

{

Console.WriteLine("You have entered the wrong password too many times. You are now locked out.");

}


}

else

{

Console.WriteLine("The Password is incorrect. You have 1 more attempt.");

UserPassword = Console.ReadLine();

Console.Clear();

}

}

else

{

Console.WriteLine("The Password is incorrect. You have 2 more attempts.");

UserPassword = Console.ReadLine();

Console.Clear();

}

}

else

{

Console.WriteLine("Please enter the passowrd!");

UserPassword = Console.ReadLine();

Console.Clear();

}

if (password == UserPassword)

{


}

else

{

Console.WriteLine("The Password is incorrect. You have 2 more attempts.");

UserPassword = Console.ReadLine();



}

if (password == UserPassword)

{


}

else

{

UserPassword = Console.ReadLine();

Console.Clear();

}

if (password == UserPassword)

{


}

else

{

Console.WriteLine("The Password is incorrect. You have 1 more attempt.");

UserPassword = Console.ReadLine();


}

if (password == UserPassword)

{

Console.WriteLine("Access Granted! ;)");

Console.Clear();

int monbal = 450;

Console.WriteLine("Current Money Balance : " + monbal);

Console.WriteLine("Would you like to withdraw some money? Y or N.");

string take = Console.ReadLine();

Console.Clear();


string idk = "Y";

string idk2 = "N";

if (take == idk)

{


int money;

Console.WriteLine("How much?");

money = int.Parse(Console.ReadLine());

if (money > monbal)

{

Console.Clear();

Console.WriteLine("Sorry, but you dont have that much money! :(");

}

else if (money < monbal)

{

Console.Clear();

Console.WriteLine("Sure thing!");

int monbal2 = monbal - money;

Console.Clear();

Console.WriteLine("You now have " + monbal2 + " money left! ;)");

}

else

{

Console.Clear();

Console.WriteLine("I'm sorry, but that is not a valid number...");

}

}

else if (take == idk2)

{

Console.WriteLine("Ok,that's fine. Bye.");

}

else

{

Console.WriteLine("I'm sorry, but i dont quite understand that.");

}

}

else

{

UserPassword = Console.ReadLine();

}

if (password == UserPassword)

{


}

else

{

Console.Clear();

Console.WriteLine("You have entered the wrong password too many times. You are now locked out.");

}[/CODE]
 
Hey there.

I'm not a C# programmer, but I've got a few questions I'd like to ask.

While I know that this is a beginner's project, why did you make this in the first place(Please don't interpret me as being rude in any of my questions)? I ask as I could just easily go onto the website for my bank, login, and deal with my money from there. Thus' this doesn't really serve a purpose.

AJumboKestrel1432 said:
Hop u find it useful.
Again, as I said, this doesn't really serve a purpose. Plus, on your profile, you claim to be an "experienced coder" in C#. Quite a bold statement to make, is it not? I mean, if you were "experienced" in C#, I would expect this to have a GUI client and the ability to login to my bank from that client.

This program lacks any of that. It's simply a basic terminal application that I'm assuming you wrote for fun and are not taking it seriously.

Regarding the code itself, it is nothing but a chain of if and else-statements. I'm 100% sure there is a more effective way of comparing strings in C# rather than having to use if-statements all the time.

Again, please do not take any of this to heart. It is simply just feedback I'm giving you, alongside a question that questions the authenticity of your experience.
 
Um..What do u mean by troll?
Look, I don't mean to de-rail the thread or insult you or anything. But that's just the feeling that I'm getting from you. Your very few and short messages, bundled with amateur-level code while also bearing the title of "experienced coder in C#", again, gives off that sort of feeling.

Again, do not take any offense to this. I'm simply just questioning the authenticity of that statement in your signature, as the code you have written does in no way, stand-up to "experienced" quality.
 
When u say troll do u think im a bot or im not an experienced coder or something along the lines of that?
Look, I think it's best that we take this to PM rather than this thread. I don't want this thread to get de-railed into some silly argument and I certainly do not want to get into trouble out of something that was taken out of context too quickly.

But to put simply, I am not saying you are a troll nor' do I think you are a bot. "Troll" was just the feeling that I was getting, as there was somebody else a while back who wrote extremely tiny messages. They were more than likely a troll, but just because I'm being somewhat reminded of them, does not mean that I am deliberately calling you one. So to put simply, no. You are not a troll.

Although, you definitely are not an experienced coder - Even in C#. You have literally written one of the most massive if-else chains that I have ever seen in my life, when there definitely is a more effective, compact, and cleaner way of doing the same thing that doesn't involve that many if-else statements. I know that you are just doing this for fun, but I would recommend that you at least look over your code, see what can be done to improve it, and then instead of randomly slapping it onto a new thread without any text attached to it, actually ask what can be done to improve it. I have already giving my suggestion and that's hinting at the fact that there is a more efficient way of doing this, without the use of so many if-else statements.
 
@GameZee, there was literally no reason for you to just put up your reaction.

Also, are you the owner of this other account that I was talking to? The writing-style belonging to the both of you are the exact same and the both of you know C# too.
 
GameZee said:
@AJumboKestrel1432 Also,why do u have '
Console.BackgroundColor = ConsoleColor.Black;'?
It literalyy does nothing important and changes nothing
I don't know what you're saying, as you literally change the foreground(Text) colour of your own programs. As can be seen in this thread: https://www.codeforum.org/threads/bomb-defuse-game.959/unread

You're essentially criticizing yourself at this point.

GameZee said:
No,im not
I don't necessarily believe you. Both of you are C# programmers; both of you changed the terminal colours; both of you have the exact same style of writing; and I do recall @AJumboKestrel1432 posting the bomb-defuse game script on his account. Although, perhaps I misinterpreted what was your script to be his script. That or the Mandela Effect is settling in on me again.

I'm not being rude or anything, but there's just too much evidence in my opinion for you to deny.
 
@Mathematical. In my post where i said putting Console.BackgroundColor = ConsoleColor.Black; does nothing important, i said it because the console background colour is already Black. Also, in my post i put: Console.ForegroundColor,not Console.BackgroundColor,which means i did not do the same as @AJumboKestrel1432 The two functions DO NOT do the same thing. Foreground colour is for the text. Background is AROUND the text :0
 
Last edited by a moderator:
@Mathematical. In my post where i said putting Console.BackgroundColor = ConsoleColor.Black; does nothing important, i said it because the console background colour is already Black.
Yeah, I do agree that it is useless as it changes the colour. But, one thing to note is that some people(Myself included) don't have their backgrounds as black. Theirs may be white, grey, navy-blue, you get the idea. Although, I do think it still is useless as one would want their terminal-colour to remain the same as it was before.

Also, in my post i put: Console.ForegroundColor,not Console.BackgroundColor,which means i did not do the same as @AJumboKestrel1432 The two functions DO NOT do the same thing. Foreground colour is for the text. Background is AROUND the text :0
I know that. I know the difference between the foreground and the background, and the fact that both functions do completely different things.

Now while I'm not sure I am allowed to disclose this, as a staff-member, I am able to see posts that have been deleted. You do have a deleted post stating that you are @AJumboKestrel1432. I can understand if you may have wanted a fresh start, especially since I may have come down as a bit harsh when you were on that account. Either way, there was no purpose in creating another account, as I could easily tell that you were who you claimed not to be. If you no longer want to keep that account in CF's database though, feel free to PM either me or @Master Yoda and we can delete @AJumboKestrel1432 for you.

The reason I am coming down as harsh on you is because I am trying to give critical feedback that will be beneficial to you as a programmer. Things such as not leaving in explanations of what your code does(Even in the code itself via comments), will not benefit either you or your co-workers and anybody else that contributes to your code in open-source development. Also, you want to make sure that you know what it is you're talking about. The last thing you want to do is give away false information that nobody will benefit from(See this thread, for when I had to correct you: https://www.codeforum.org/threads/how-to-make-an-array-in-c.964/#post-6500). Again, I am not trying to be rude. I'm trying to help and so is everybody else. Remember that now.
 
Yeah, I do agree that it is useless as it changes the colour. But, one thing to note is that some people(Myself included) don't have their backgrounds as black. Theirs may be white, grey, navy-blue, you get the idea. Although, I do think it still is useless as one would want their terminal-colour to remain the same as it was before.


I know that. I know the difference between the foreground and the background, and the fact that both functions do completely different things.

Now while I'm not sure I am allowed to disclose this, as a staff-member, I am able to see posts that have been deleted. You do have a deleted post stating that you are @AJumboKestrel1432. I can understand if you may have wanted a fresh start, especially since I may have come down as a bit harsh when you were on that account. Either way, there was no purpose in creating another account, as I could easily tell that you were who you claimed not to be. If you no longer want to keep that account in CF's database though, feel free to PM either me or @Master Yoda and we can delete @AJumboKestrel1432 for you.

The reason I am coming down as harsh on you is because I am trying to give critical feedback that will be beneficial to you as a programmer. Things such as not leaving in explanations of what your code does(Even in the code itself via comments), will not benefit either you or your co-workers and anybody else that contributes to your code in open-source development. Also, you want to make sure that you know what it is you're talking about. The last thing you want to do is give away false information that nobody will benefit from(See this thread, for when I had to correct you: https://www.codeforum.org/threads/how-to-make-an-array-in-c.964/#post-6500). Again, I am not trying to be rude. I'm trying to help and so is everybody else. Remember that now.
Ok
 
Hey there.

I'm not a C# programmer, but I've got a few questions I'd like to ask.

While I know that this is a beginner's project, why did you make this in the first place(Please don't interpret me as being rude in any of my questions)? I ask as I could just easily go onto the website for my bank, login, and deal with my money from there. Thus' this doesn't really serve a purpose.


Again, as I said, this doesn't really serve a purpose. Plus, on your profile, you claim to be an "experienced coder" in C#. Quite a bold statement to make, is it not? I mean, if you were "experienced" in C#, I would expect this to have a GUI client and the ability to login to my bank from that client.

This program lacks any of that. It's simply a basic terminal application that I'm assuming you wrote for fun and are not taking it seriously.

Regarding the code itself, it is nothing but a chain of if and else-statements. I'm 100% sure there is a more effective way of comparing strings in C# rather than having to use if-statements all the time.

Again, please do not take any of this to heart. It is simply just feedback I'm giving you, alongside a question that questions the authenticity of your experience.
A little condescending, don't you think?
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom