✅ The code doesnt work as intended
The user is suppoed to write how many points(poäng) the user have, for example 100 points, and the program will then show that the user got the grade A. 100 points = grade A
But the program gives you the grade F whatever the input is, I have googled and checked fullstack
23 Replies
Try debugging this code
$debug
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
It will let you see what variable has what value at which point
At a glance, though, the poang array doesn't ever seem to have any values added to it
LasPoang returns an array of numbers, yes
But you do nothing with it
I assume you want that to become your new poang array
Im not quite sure what you mean 😢
static int[] LäsPoäng(string[] ämnen)
LasPoang returns an array
LäsPoäng(ämnen); //
But you never do anything with it
So your poang
array remains emptyHow do i bridge them together if I may ask? Im doing this as an exercise from a book to learn But its very poor instructions… like it doesnt mention how to do this part
How do you get a value from a method?
Say, from
Console.ReadLine()
?
If you wanted to print to the console the exact thing the user typed in, how would you do that?
Console.ReadLine()
returns a string?
You call it in the main code?
You have it right in your code
Console.ReadLine()
returns a value
You save it in a Gitliga_poang
variable
And use it later
Similarly, you can save the value returned from LasPoang()
in a variable
And use it in Omvandla()
Trying to understand and do this😅
Thank you btw for taking your time and looking over my bad code
LasPoang is the
Console.ReadLine()
here
And Omvandla is the Console.WriteLine()
One method needs the values returned by anotherSo the error is with LasPoang 🤔
LasPoang is fine
The fact that you call it without getting a value out of it, is not
You tell someone "chop some onions for me, I'll use them later to make soup"
Then you throw away those chopped onions
And are surprised that your soup has no onion in it
What you are doing is
I love your example
but does the calling LäsPoäng(ämnen); not use the stored values then?
Where?
How?
in the static void main
damn i suck at this lol
half of it is like greek
How does it get the values into the
poang
array, in your mind?so omvandla needs to use laspoang somehow trying to figure it out sorry for being such a mess
im trying to call laspoang in the omvandla method but that doesnt seem to work either..
omg I got it
I didnt quite get it but it finally clicked where to write what
thank you so much
ive been going at this for 4 hours, no kidding
im probably the worst beginner there is
Oh not even close lol
We had plenty of threads that spanned days
There are people who are just learning-resistant out there
Im most likely one of them lol, I forget half the things I learn ._.
I kinda crave for onion soup now