We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have an assignment and I just do not understand what it is that I have to do.
My assignment says: 1. Write a function in Processing, called “Operations” which will receive 3 values: int operType, int operand1, and int operand2. This function will perform a different operation based on operType:
operations(1,2,3); = Perform the addition of 2+3 operations(2,2,3); = Perform the multiplication of 2*3 operations(3,2,3); = Perform the subtraction of 2-3 operations(4,2,3); = Perform the division of 2/3 operations(5,2,3); = Perform the exponent of 23
The function should be of type float and return the result to the setup method for you to print it there HINT: Use if statements in your method to determine what operation you should use.
I understand how to do "calculator commands" as we call them in class but I do not understand what I have to do with the float.
Thank you.
Answers
it's always best to start writing your code and then show it here
you could call the function called “Operations” from draw() and use the return value (aka the result) in a println statement.
;-)
I have this so far.
ok...
the func "operations" should return something...
you need to replace void by a type it should return...
hint: see assignment
also, you need to println the result the function is returning (that is in draw(), but in the assignment it says, do it in setup())
when you use println, you don't need pdf
println just prints to the text console
in the function, what would you do with "opertype" ?
Hint: see assignment
;-)
So you get the idea…
A
switch
, might be a good idea also...Untested:
@vk I just read the plagiarism thread and I think you did too much for him in your answer.
I think I told him what to do and he should do it himself to learn.
So, no offence, I flaged your post, just to see happens next...........
Best, Chrisir
;-)
@Chrisir, for forum rules we've gotta look at the link below, not that "plagiarism" thread:
http://forum.processing.org/two/discussion/8042/processing-forum-rules-and-advices
Here's the "Homework" excerpt: B-)
yeah, thanks for emphasizing my point here
@Chrisir, I believe you've misunderstood the excerpt: :|
The whole article is mostly about advises. Only a tiny portion of them are rules!
An OP can simply paste the text assignment even though it's not the best procedure.
And we aren't "law" cops for our fellow answerers either! =;
Dear @Chrisir, I don't think so. But that's me. Where is the line? I've learned a lot from code in answers. I believe some times code is very eloquent. And this code can't be used as the answer to the assignment. To adapt it, one got to understand it. I would answer my son like this.
But, again, that's me.
I think it was clear that my intention was not to prevent or disturb OP's learning process.
If care is not exercised to stay balanced in this matter, it can backfire, ending in preventing people to help others, afraid of forum's reaction. Good help can be lost... I do learn a lot from code answers.
I think the point (about plagiarism) is made, and every one here agrees that no one should provide full code solutions, in a manner that the code could be used for cheating. But we don't need a patrol. If I was wrong, and crossed the line in this specific one here, well it was a little, with no intention. Not a big deal. Very few times (maybe 2 or 3) I've seen in this forum answers that could be used for cheating. And even those, were not clear about being assignments in first place... I believe we can relax a little in this particular matter. I think if we look back, before this discussion started, we will see a forum where this matter was not a big problem, and things were running smoothly. And again the point about plagiarism is clearly made by all the discussions on this issue. The only disagrees that still happening it is not if plagiarism is acceptable, its's not. They are about where to draw the line. My point is: the community common sense is good enough where it is... the line is well placed, we can relax and enjoy.
This only is my humble opinion. Do what you got to do with my post. Flag, delete, ban... It's ok.
:)
edit: You see, before posting my judgment is the only one available... So I'll keep going by it. Once posted, then there is the community judgment, so judge... That's expected.
peace, love and code !
no offence...
you are doing great work here since years
;-)
I did not fill offended. :) cheers
:)>-
Cheers mate!
@itgoesvnaaa :
I think you can not pass a sign like + to a function
Did it work?
I guess you need to say
'+'
instead, so it's a char.Anyway, in the assignment it says use 1,2,3,4 where you have +, * etc.
So passing 1 as the first parameter tells the function, "hey, we want to use + later on".
read your assignment carefully. It's all in there.
e.g. it says:
Chrisir ;-)