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

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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
