❔ Homework Help. Make every element in char array alternate between upper and lowercase: LiKeThIs
I am working on an assignment where I am given a char[] words, and must convert it so that the characters in the array alternate between upper and lowercase. Any help on where to start?
46 Replies
Little update, I ran the program to check the random inputs a few times and it looks like all the inputs are fully uppercase, so I will just need to convert ever other index to lower. Seems that even indexes are upper and dd indexes should be lower.
Hi
So if the word is "good"
You'd need it as G,o,O,d ?
yes
You could loop over the char array and divide every index number by 2
this is what i have so far
You need to add condition for when index is 0 as well
|| i == 0
?
If index = 0 then upper
Yeah
okay
so then I would just convert the even indexes to lower
lemme check if expected outputs want 0 as upper or lower
Sure
okay i read it wrong, even indexes are upper, odd indexes are lower.
so maybe i could do
to check that they are not even
and then do ToLower?
Yes
If i % 2 is anything else than 0 then it it's odd
okay
so what would the proper syntax for tolower in this situation?
i tried
no clue
Do one thing
Make the word into a char array
Like this
it starts as a char array
Oh sry, then it's easy. This should work
1 sec
this is the error im pulling
Just do this
Word[i].tolower()
ok
no overload method, takes 0 srgs
args*
??
Can you show the error
Oh i guess since it's already lowercase it's throwing that error
Refer this
would i have to do like i => 'A' && i <= 'Z'
oh okay thank you
i will look at that
It's
char.ToLower('A')
not 'A'.ToLower()
Bingo, sry this is the way to go @apparition
got it
🙂
thank you for your help shinigami
and zzzzzzzzzzzzzz
even tho i didnt see ur message hhaha
Np 😉
now how do i set this question as solved?
/close or something like that
Not really sure, I'm new too
okok
thank you again, appreciated very much
/close
$close maybe?
Use the
/close
command to mark a forum thread as answeredNope
for some reason it keeps saying “the application did not respond” when i try to /close
the bot is having issues. its fine, just leave it
SlimStv#2835
REPL Result: Success
Console Output
Compile: 701.661ms | Execution: 50.137ms | React with ❌ to remove this embed.
fun homework you got there.. just answering for fun
your answer is great, unfortunately, we arent allowed to use var
Just use the actual type, then
var
is not magic
and
are the exact samei
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.