Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you answer for both java and c ++, thanks. 1 Functions to Write This is an e

ID: 3742340 • Letter: C

Question

Can you answer for both java and c ++, thanks.

1 Functions to Write This is an easy, almost, trivial, assignment even if you have never used C++ before. Some of the assignment may not be graded. We want to implement in both C++ and Java, pass by reference of integers. In each, we implement the following (very badly designed) methods/functions: // square(i) sets i to i-i, and returns neu i // tvice(i) setsi to 2i, and returns nex i // once(i) returns i These methods/functions, implementable in both C++ and Java, perform operations that can never be done in mathematics, and as such, a good case can be made for not allowing them in programming anguages either. I hope you would never write code like this for real.) But, as said, they can be implemented in both C++ and Java. In C++, pass by reference of an int can be implemented directly and easily. In Java, it is more difficult: we cannot ; use ints ast are immutable and cannot be updated. We must be in a separate file. The main function in C++ is: will therefore create a mutable integer class, Int, which main() int x 3; int y square (x) twice(x)once (x) y45, not 18 cout

Explanation / Answer

C++: ----- #include using namespace std; int square(int &x) { x = x*x; return x; } int twice(int &x) { x = x*2; return x; } int once(int &x) { return x; } int main() { int x = 3; int y = square(x) + twice(x) + once(x); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote