SNIP

I WILL BE REALLY THANKFUL TO YOU:pretty:

C) - Translate the following scenario to a Java Program: [10 M]
We assume that an array a of size n and a key x are given.
We are supposed to find an i satisfying the above specification.

``````For i = 0,1,...,n-1,
if a[i] is equal to x
then we have found a suitable i and hence we stop.

If we reach this point
then x is not in a and hence we terminate with i = -1.
``````

Question 4: Arrays[20 Marks]
Complete the following program so that it reverses the order of the values in data array, then prints it out. [10 M]
import java.io.*;

``````class ReverserVersion1
{
public static void main (String[] args)
{
int[] data = {1,2,3,4,5,6,7,8,9,10,11,12,13,14};
// reverse the data
for (int j=0; j < be careful here; j++)
{

}
// write out the new data
for ( int j=0; j < data.length; j++)
{

}  }}
``````

Now write another program that uses two arrays. The first array data is not changed. The second array result gets the elements of data in reversed order. [10 M]

Exercise 5: For loop [20 Marks]
A breeding group of 20 bighorn sheep is released in some protected area. It is expected that with careful management the number of sheep, N, after t years will be given by the formula:
N = 220/ (1 + 10(0.83) t ) //Notice the place of t as power
and that the sheep population will be able to maintain itself without further supervision once the population reaches a size of 80.
Write a program (using a for loop) that writes out the value of N for t starting at zero and going up to 25. How many years must the sheep heard be supervised?

Question 6: Switch [20 Marks]

Write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line.
Read in the line into a String (in the usual way). Now use the charAt () method in a loop to access the characters one by one.
Use a switch statement to increment the appropriate variables based on the current character. After processing the line, print out the results.

THANKS
mail me at
SNIP

Edited by Reverend Jim: Fixed formatting

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span

Nobody is going to do your project for you. Either read the forum rules or go away.

Well, it's quite disappointing and appalling that you haven't given it even a thought and just copied-pasted the whole assignment on the forum. You didn't specify anything as to what you think about the problem and what obstacle you think there is.
I hope you don't post again; not such a post, at least.

I hope you don't post again; not such a post, at least.

Even though you are right, that was rather rude. You could have suggested for mmmusa to post what he has done so far if he/she want some real help, instead of discourage him like that

Well, it's not about what he wrote. It's about his approach to problems and the expectation of spoon feeding which, by all means, should be discouraged. At least this is what I think.

Well, it's not about what he wrote. It's about his approach to problems and the expectation of spoon feeding which, by all means, should be discouraged. At least this is what I think.

Of course that kind of behavior should be discouraged. I just thought that this:

``I hope you don't post again; not such a post, at least.``

was somehow . . . too direct.

Anyway, by the looks of it, it doesn't seem that the OP will return with some code of his own

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.