AssignmentAdvancedC 2023
AssignmentAdvancedC 2023
1. Define a class named Money that stores a monetary amount. The class should have
three private integer variables, one to store the number of thousands, other to store
hundreds and another to store tens.
- Add a constructor
- Add accessor and mutator functions to read and set both member variables.
- Add a function that returns the monetary amount as an integer.
- Add a function that add two money (while adding two money, if the number of
hundreds is greater or equal to one thousand or the number tens is equal or greater
than hundred you have to perform conversion )
Write a program that tests all of your functions with at least three different Money objects
3. Write two versions of a function that takes two integers x and y as parameters and returns the first
integer raise to the power of the second (xy). You may assume that the second argument is positive.
3.2. The second version of the function should be iterative (using a loop)
4.
5. The greatest common divisor, or GCD, of two positive integers n and m is the Largest number j, such
that n and m are both multiples of j. Euclid proposed a simple algorithm for computing GCD(n,m),
where n > m, which is based on a concept known as the Chinese Remainder Theorem. The main idea of
the algorithm is to repeatedly perform modulo computations of consecutive pairs of the sequence that
starts (n,m, . . .), until reaching zero. The last nonzero number in this sequence is the GCD of n and m.
120 mod 12 = 0
5.2. The second version of the function should be iterative (using a loop)