Read Section 4.5 in Chapter 4 and Sections 8.1-8.8 and 8.12 in Chapter 8 in the textbook, and then answer the following questions.
double [] a = {-10.2, 23.1, 41.7, -31.8, 0.0};
double temp = a[0];
for (int i = 1; i < a.length; i++) {
if (a[i] > temp) {
temp = a[i];
}
}
System.out.println (temp);
public static int foo(int [] a)
{
int temp = 0;
for (int i = 0; i < a.length; i++) {
if (a[i] >= 0) {
temp++;
}
}
return temp;
}
public static char [] bar(String [] a)
{
char [] tmp = new char[a.length];
for (int i = 0; i < a.length; i++) {
if (a[i].length() > 0) {
tmp[i] = a[i].charAt(0);
}
else {
tmp[i] = ' ';
}
}
return tmp;
}