I have tried a few times to get this and I don\'t think its correct,please give
ID: 3614946 • Letter: I
Question
I have tried a few times to get this and I don't think its correct,please give me another opinion. With the first question, pleaseexplain the steps so I can better understand what it is im doingwrong.- What does this method do? Please describe the task accomplishedby this method.
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;
}
2. Write a class/static method that takes an array of ints as a
parameter and returns true if the number of positive values in
the array is greater than then number of negative values, and
false otherwise.
Explanation / Answer
please rate - thanks part a --takes the first letter of each word of a string andcreates a new "word". if the word is "blank" its a space so if the words are "this","longer","why","not"," ","who","guess" it will return tlwn wg public static char [] bar(String [] a){char [] tmp = new char[a.length];for (int i = 0; i 0) { //check how many characters in the stringtmp[i] = a[i].charAt(0); //if not 0, put 1st letter in tmp}else {tmp[i] = ' '; //if 0 put blank in temp}}return tmp; //return tmp array to main} part 2 import java.util.*; importjava.io.*; public class untitled { public static void main(String[] args) { int []c={1,-2,-3,4,5,-6,7,-8,9,-11,12,-13}; System.out.print(negorpos(c)); } public staticboolean negorpos(int [] a) {int i,pos=0,neg=0; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.