Results 1 to 5 of 5
 12162009, 12:04 PM #1Member
 Join Date
 Dec 2009
 Posts
 1
 Rep Power
 0
Please I need the solution to this
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 zeroshifted 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 zeroshifted 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 zeroshifted 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 zeroshifted array does not require that there be nonzero elements in the array.
{1, 2, 3} 1 The definition of zeroshifted array does not require that there be zerovalued elements in the array. All it says is that if there are zerovalued elements they must all be at the end.
{} 1 Since neither zeroes or nonzeroes 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
 12162009, 12:13 PM #2
Nobody will do your work. Follow the link in my signature.
Math problems? Call 1800[(10x)(13i)^2][sin(xy)/2.362x]
The Ubiquitous Newbie Tips
 12182009, 04:45 AM #3Member
 Join Date
 Dec 2009
 Posts
 1
 Rep Power
 0
I need a solution for that too....
 12182009, 05:21 AM #4Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,643
 Rep Power
 13
@Z: If you're interested in Java to be wanting to pass tests and things, why waste your time with pointless posts when the OP of this thread has given you a great opportunity by posing tasks for which you could write some code?
@Both: "Please, help me"? That's like saying "Please help me to lose weight by exercising for me." The point of tasks like the ones posted here is that you benefit by writing the code. Yourself. And once you start you will be in a position where others can help.

Similar Threads

Please give me a solution
By ivvgangadhar in forum AWT / SwingReplies: 5Last Post: 11142008, 02:43 PM 
solution for my project
By shkelqa in forum AWT / SwingReplies: 4Last Post: 05282008, 10:31 PM 
solution for my project
By themburu in forum Java AppletsReplies: 4Last Post: 05212008, 01:03 PM 
Please need solution
By prithvi in forum New To JavaReplies: 4Last Post: 04222008, 01:27 PM 
Friends could u plz give me solution 4 this
By Saritha in forum JDBCReplies: 1Last Post: 06152007, 04:42 PM
Bookmarks