Home
Blog
Careers
Forums
Downloads
FM24 Real Name Fix
FM23 Real Name Fix
FM24 New Leagues
FM23 New Leagues
FM24 Tactics
FM24 Data Update
FM Database
FM Guides
FM Shortlists
FM24/25 Update Wonderkids
FM24/25 Update Free Players
FM24/25 Update Bargains
FM24/25 Update Players to avoid
FM24/25 Update Club Budgets
FM24/25 Update Club Facilities
Graphics
Installation Guides
Records
Prediction League
Fantasy Football
Search
chokosc
For our first project we need to think of a problem and solve it. I decided to go as close as possible to what we did in class. What we did in class is take a word, change it's first letter to a capital letter and then put the capital letter back. The problem is that it was only the first letter and not the rest of the word.
So I decided to try and get the whole word in and this is what I got so far:
start:
Console.WriteLine("Please enter a word below:"
Console.WriteLine(""
string str = Console.ReadLine();
char char1;
if (str[0] >= 97)
{
char1 = (char)(str[0] - 32);
}
else
{
char1 = (char)(str[0] + 32);
}
char char2 = (char)(str[1]);
char char3 = (char)(str[2]);
char char4 = (char)(str[3]);
char char5 = (char)(str[4]);
Console.WriteLine(""
Console.Write(char1);
Console.Write(char2);
Console.Write(char3);
Console.Write(char4);
Console.WriteLine(char5);
goto start;
The problem with that is that it has to be a 5 letter word. if it is lower than that, it just gives me an error and if it is more than that it doesn't finish the word.
So my question is: is there a way to use if and tell it how many chars we need, depending on how many letters there are? So basically:
if amount of letters = 2
char char2 = (char)(str[1]);
if amount of letters = 3
char char2 = (char)(str[1]);
char char3 = (char)(str[2]);
and so on.
Thanks for any help!
Phoenix Arrow
You'd need to make char2, char3, char4 etc an array though. Then make a loop which goes as long as char.length - 1.
chokosc
chokosc
What do you mean?
Phoenix Arrow
chokosc
I found this website that explains arrays but I am not sure which to use and how.
http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx
Phoenix Arrow
I think that's about write. But I haven't done any programing since May and that was web stuff. I haven't done any C++ since Jan 2011 and I haven't done any C# since a year before that because I do more IT support now than programming so I'm really rusty and was bad at it to begin with. I also don't really know what you've done before or what you're meant to be using. If you're stuck, talk to your lecturer. If you're stuck and you don't want to ask your lecturer, try asking on stackoverflow.com. Make sure you make it clear you're a beginner though or you might get a bunch of shit back which makes no sense.
chokosc
in the Console.WriteLine?
chokosc
Phoenix Arrow
Phoenix Arrow
chokosc
Telegram Sam
Phoenix Arrow
Telegram Sam
Go right ahead.
Deano
chokosc
Sad to hear that! Have the next 3 years to study this
Phoenix Arrow
It is fun though, it's just not a doss subject.
chokosc
Someone on the website you showed me wrote down a working code. It is full of things that I don't know yet so I'll just ask my teacher what to do. Maybe he'll tell me it is enough (what I have already done) seeing as how we haven't really learnt much.
Slashman X
Programming is class