C
C#•3y ago
Krispy

Help [Answered]

I want to use the result of the function before in the function below, and I cant add more args in the parentheses to copy the code from the one above. What do I do
53 Replies
Krispy
KrispyOP•3y ago
ignore writing its in french lol
TheBoxyBear
TheBoxyBear•3y ago
You need to call the method to get the return value. CalculerCoutRevient(0, 0)
Krispy
KrispyOP•3y ago
0, 0 will work?
TheBoxyBear
TheBoxyBear•3y ago
It's example values passed to that method Use the values you need in the context where you're calling
Krispy
KrispyOP•3y ago
here ill give you some context
TheBoxyBear
TheBoxyBear•3y ago
After that, the call itself becomes the return value you can insert anywhere a value is needed
Krispy
KrispyOP•3y ago
our teacher gave us this program, basically we write 5 functions, and when we make them work we dont actually see anything it just produces a txt file that says if we got the coding right or not bc he programmed something himself in the background
TheBoxyBear
TheBoxyBear•3y ago
Based on the name of the parameters, you'll need to get the values externally and insert them in the call From quebec šŸ™‚
Krispy
KrispyOP•3y ago
u? same
TheBoxyBear
TheBoxyBear•3y ago
lol Server rules still require english though
Krispy
KrispyOP•3y ago
yeah english and french aint my first language anyways I can speak both fluent so doesnt matter to me ill test with 2 values see if it works
TheBoxyBear
TheBoxyBear•3y ago
It's like functions in math, f(x) takes in a number and refers to it as x in the formula So f(x) in c# would be int f(int x)
Krispy
KrispyOP•3y ago
I see I gotta put f after a float value right
Krispy
KrispyOP•3y ago
Krispy
KrispyOP•3y ago
Like this
TheBoxyBear
TheBoxyBear•3y ago
Without the f, the constant is int but because it's put where a float is needed, it gets converted to float before calling
Krispy
KrispyOP•3y ago
okok so no need
TheBoxyBear
TheBoxyBear•3y ago
So the f is optional
Krispy
KrispyOP•3y ago
Krispy
KrispyOP•3y ago
šŸ‘€
Krispy
KrispyOP•3y ago
TheBoxyBear
TheBoxyBear•3y ago
Decimal constants without a suffix are double
Krispy
KrispyOP•3y ago
so I do need the f
TheBoxyBear
TheBoxyBear•3y ago
That's my bad, I thought you were talking about 120
Krispy
KrispyOP•3y ago
oh lol
TheBoxyBear
TheBoxyBear•3y ago
Double is more precise than float so it can't safely convert any double so requires an explicit conversion
Krispy
KrispyOP•3y ago
well there are no issues but it doesn't work I think I messed up the calculation formulas
Krispy
KrispyOP•3y ago
Krispy
KrispyOP•3y ago
on this txt file its supposed to show dots instead of Xs if everything works right like if the tests are executed and gives the results I can show u the teacher's code šŸ˜‚
Krispy
KrispyOP•3y ago
Krispy
KrispyOP•3y ago
Idk if this will be helpful for you
TheBoxyBear
TheBoxyBear•3y ago
Strange nullables are disabled
Krispy
KrispyOP•3y ago
we always disable them its my first month with C# btw
TheBoxyBear
TheBoxyBear•3y ago
Maybe just to not confuse students with errors. In practice though it's useful to have. Can testify it saved me from countless null related bugs
Krispy
KrispyOP•3y ago
u got any idea how to fix my coding or
TheBoxyBear
TheBoxyBear•3y ago
Looking into it
Krispy
KrispyOP•3y ago
šŸ‘
Krispy
KrispyOP•3y ago
there are no helpful formulas online tbh, I made this formula myself
Krispy
KrispyOP•3y ago
maybe thats why it failed. Idk the proper formula
TheBoxyBear
TheBoxyBear•3y ago
Cout revient as mentioned is calculated from the other method so you can remove that parameter
Krispy
KrispyOP•3y ago
u can read french right
TheBoxyBear
TheBoxyBear•3y ago
Yes For the formula, I can't say exactly why it doesn't work but if I were to do it, I would start by calculating how much I need to produce to compensate for the expected loss
Krispy
KrispyOP•3y ago
Krispy
KrispyOP•3y ago
He wanted 4 parameters šŸ¤·ā€ā™‚ļø
TheBoxyBear
TheBoxyBear•3y ago
Did you write the comment yourself? That one mentions getting prix revient from excercice 2
Krispy
KrispyOP•3y ago
the green here? I didnt was already there its the same as whats written here
TheBoxyBear
TheBoxyBear•3y ago
Unless they meant an embeded call like CalculerPrixVente(0, 0, CalculerPrixRevient())
Krispy
KrispyOP•3y ago
hmm
TheBoxyBear
TheBoxyBear•3y ago
Then you should use the parameter instead of calling it yourself Imo I would ask for clarification on the assignment.
Krispy
KrispyOP•3y ago
yeah its a bit unclear for beginners šŸ™ˆ
TheBoxyBear
TheBoxyBear•3y ago
You can still do the rest and sort out that small issue afterwards
Krispy
KrispyOP•3y ago
the other functions you mean ill have to rush it in from 9pm due before 12 am and I got work in 50m šŸ™ˆ ill see what I can do ty for helping
Accord
Accord•3y ago
āœ… This post has been marked as answered!

Did you find this page helpful?