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
ignore writing its in french lol
You need to call the method to get the return value.
CalculerCoutRevient(0, 0)
0, 0 will work?
It's example values passed to that method
Use the values you need in the context where you're calling
here ill give you some context
After that, the call itself becomes the return value you can insert anywhere a value is needed
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
Based on the name of the parameters, you'll need to get the values externally and insert them in the call
From quebec š
u?
same
lol
Server rules still require english though
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
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)
I see
I gotta put f after a float value right
Like this
Without the f, the constant is int but because it's put where a float is needed, it gets converted to float before calling
okok so no need
So the f is optional
š
Decimal constants without a suffix are
double
so I do need the f
That's my bad, I thought you were talking about 120
oh lol
Double is more precise than float so it can't safely convert any double so requires an explicit conversion
well there are no issues but it doesn't work I think I messed up the calculation formulas
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 š
Idk if this will be helpful for you
Strange nullables are disabled
we always disable them
its my first month with C# btw
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
u got any idea how to fix my coding or
Looking into it
š
there are no helpful formulas online tbh, I made this formula myself
maybe thats why it failed. Idk the proper formula
Cout revient as mentioned is calculated from the other method so you can remove that parameter
u can read french right
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
He wanted 4 parameters š¤·āāļø
Did you write the comment yourself? That one mentions getting prix revient from excercice 2
the green here?
I didnt
was already there
its the same as whats written here
Unless they meant an embeded call like CalculerPrixVente(0, 0, CalculerPrixRevient())
hmm
Then you should use the parameter instead of calling it yourself
Imo I would ask for clarification on the assignment.
yeah its a bit unclear for beginners š
You can still do the rest and sort out that small issue afterwards
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
ā
This post has been marked as answered!