Please, help me.I am new to java

1. Write a function named countRepresentations that returns the number of ways that an amount of money in American dollars can be represented in American bills. The signature of the function is:

int countRepresentations(int numDollars)

For example countRepresentations(12) should return 4 because 12 dollars can be represented in the following four ways.

12 one dollar bills

1 five dollar bill plus 7 one dollar bills

2 five dollar bills plus 2 one dollar bills

1 ten dollar bill plus 2 one dollar bills

For this question assume that American bills occur only in denominations of 1, 5, 10 and 20 dollar bills.

Hint: Use a nested loop that looks like this. Please fill in the blanks intelligently, i.e. minimize the number of times that the if statement is executed.

2. The mathematical constant pi can be approximated using the following infinite sequence:

4 - 4/3 + 4/5 - 4/7 + 4/9 .... + (4*(-1)n)/((2*n)+1). This was discovered around 1400 by the Indian mathematician Madhavan Namboodiri and was rediscovered by Gottfried Liebniz about 300 years.

Write a function named approximatePI that returns the value of this sequence after a given number of iterations. If the number of iterations is less than or equal to 0, the function should

return -1.

The function prototype is

double approximatePI(int numIterations)

Important: There is no operator for exponentiation in Java, C#, C++ or C. In particular ^ is not the operator for exponentiation, it is the operator for exclusive or. If you use ^ for exponentiation you will receive no credit for your answer.

Examples

numIterations return Sequence

0 -1

1 4 4

2 2.666667 4 - 4/3

3 3.466667 4 - 4/3 + 4/5

4 2.895238 4 - 4/3 + 4/5 - 4/7

5 3.339683 4 - 4/3 + 4/5 - 4/7 + 4/9

6 2.976046 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11

100,000 3.141583 Sequence has 100,000 members

3. An array is defined to be zero-shifted if all zeros (if any) occur at the end of the array. For example, {3, 1, -4, 0, 0}, {0, 0, 0} and {1, 2, 3} are zero-shifted arrays but {0, 0, 1, 2, 0, 0, 0} and {1, 2, 0, 3, 4, 0} are not. Write a function named isZeroShifted that returns 1 if its array argument is a zero-shifted array, otherwise it returns 0.

If you are writing in Java or C#, the function prototype is

int isZeroShifted(int[ ] a)

If you are writing in C or C++, the function prototype is

int isZeroShifted(int a[ ], int len) where len is the number of elements in a

Examples

a return reason

{4, -1, 2, 6, 0, 0, 0} 1 All zeroes are at the end

{1, 0} 1 All zeroes are at the end

{1, 1, 1, 1, 0, 0} 1 All zeroes are at the end

{0, 0, 0} 1 The definition of a zero-shifted array does not require that there be non-zero elements in the array.

{1, 2, 3} 1 The definition of zero-shifted array does not require that there be zero-valued elements in the array. All it says is that if there are zero-valued elements they must all be at the end.

{} 1 Since neither zeroes or non-zeroes are required, this is okay.

{1, 2, 0, 3} 0 Not all zeroes are at the end.

{0, 0, 0, 1} 0 Not all zeroes are at the end.

{0, 1, 0} 0 Not all zeroes are at the end

{0} 1 All zeroes are at the end