❔ Help Me with some C# Tests?
There's a few tests in this project that I'm stuck on, and could use some help
63 Replies
Do you expect someone to just hand you 5 solutions?
@callmespriggy_8033 tell us what you've tried, and where you're stuck
I could try to get test 5 on my own (it's the separate for loop with a nested if loop that scares me) but test 6 is... I don't even know where to begin
I haven't handled chars and strings all that much yet
Do you know what a char is?
No?? Really I just want to know where to begin
characters
like a, b, c
Correct they are actually numbers behind the scenes however so they can be incremented and decremented
,,,,huh.
so just. treat them like numbers under a different name?
'a' + 1
is 'b'
that... makes sense
lemme try something
I don't think I have this right
I feel like I should decalre smth
Show us what you tried
I feel like I'm on the right track
Sure. Your expected return type is
string
thou
so what must we do, once we figured out how to get the char?add 1 to it unless it gets to
number
?that just gets us a bunch of
char
we need to end up with a string
at the end, made up of all the chars we "made"add it to a string?
That works
...how would I do that?
declare an empty string variable outside your loop
what do I set it equal to
what do you think?
starter?
question: did you write the
// for + nested while loops
comment?yea
okay
you can safely remove that 😄
you need a for loop, but no nested whiles
oh
thank god
do you understand what a for loop does and how it works?
not confidently, but yea
okay. can you walk me through what your current for loop does, and what its condition is?
currently, it doesn't do anything yet, but it's supposed to take the char given to it, add 1 to it to form a string of letters from
starter
onwards using number
, and return that stringno thats the entire method
Im asking about your for loop
it
hmm
the condition is
number
, I think
that's what tells it when to stop
rn it doesn't do anything bc I don't have anything in itwell, look at that condition
c < number
should it be <=
no, its not the comparison
but if
c
has the value of starter
than it owuld be more than
number
?yes
pobiega#0000
REPL Result: Success
Result: int
Compile: 428.249ms | Execution: 23.177ms | React with ❌ to remove this embed.
as we cna see here, 'A' is 65
so it should be >
no
but if
number
is 5...
and A
is 65...then it wouldn't work
because number is too low, right?
yea
what if we increased
number
by something, in the comparison?it would match?
what could we reasonably increase
number
by...starter?
yes!
so I put
number + starter
in the loop body?in the loop
condition
for (char c = starter; c < starter + number; c++)
this way, c
starts at starter and will increase gradually number
timesokay
so then how to I get the chars in the string we delcared
actually, what do I set that empty string to
""?
""
is indeed an empty stringah
so do I set
String
equal to starter in the loop body?well no
c?
you shouldnt use starter anymore
c
!
it auto-filled in with
String = String + c
oh my god it wokrs
HA
this is like my thrid time trying to tackle this lab and this is the farthest I've ever gottenid prefer
value += c;
where value is your string variable
but it does the same thing, just looks better,,yeah, that does look better
wait, do I even need a nested while or if loop for 7 & 8, then?
I have not read the description of either of those yet
I think I might take a break, actually- it's late and my brain is starting to get mushy lmao
thanks for your help! I really do appreciate it
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.