Hello everyone can someone please help me on my TMA..........i'm having problems in the following Q's....please provide me the codes

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 3 Years Ago by Reverend Jim*: Fixed formatting