Computers and Technology, 12.11.2019 04:31 angelica7773
Fill in the missing code: this recursive method returns "even" if the length of a give string is even, and "odd" if the length of the string is odd.
public static string foo(string s)
{
if (s. length() ==0)
return "even";
else if (s. length() = = 1)
return "odd";
else
//your code goes here
}
(40 pts) you coded the following in the file test. java :
system. out. println( foo(5));
//more code here
public static int foo(int n) //line 9
{
if (n = = 0)
return 1;
else
system. out. println(n* foo(n-1) );
} //line 15
at compile time, you get the following error:
text. java: 15: missing return statement
} //line 15
^
1 error
explain what the problem is and how to fix it.
Answers: 3
Computers and Technology, 22.06.2019 22:30
Which of the following factors would your hypothetical supervisor look at when deciding whether to test a biological material sample for dna? the amount of other evidence you have implicating a suspect in a crime the annual budget for the crime lab both of the above none of the above; you would almost always order a test
Answers: 3
Computers and Technology, 24.06.2019 21:30
Computer security/cybersecurity1) each of the following code fragments contains a number of security vulnerabilities. for each fragment, identify these security vulnerabilities and, for each vulnerability, discuss at least one way that it could be improved. note that in your discussion of how each vulnerability could be improved, you do not need to re-write a new version of the program in c; simply discuss your solution, either in pseudocode or in 1-2 sentences.a) /* file descriptor leak */#include #include int main(int argc, char *argv[]){ char *filepath = argv[0]; char *shellpath = argv[1]; file *passwords; passwords = fopen(filepath, "r"); /* read the password and do something with it */ /* . . */ /* fork and execute alternative shell */ execl(shellpath, "shell", null); }b)#include /* assume the following function is written for an electronic storefront. the user will enter the id of the item to be ordered, as well as the quantity of units that they would like to purchase. the program will then lookup the price for the price for the item using a predefined function, and return the total cost of the order.*/int gettotalcost(){ char itemid[9]; int price, unitsordered, cost; printf(" enter the 9-digit id of the item to be ordered: "); scanf("%s", & itemid); /* lookup the price according to the itemid */ price = getpricebyid(itemid); printf(" enter the quantity of units to be ordered: "); scanf("%d", & unitsordered); cost = price * unitsordered; return cost; }c)#include /* the following function is intended to return a user's full name by concatenating the user's first and last name into a single string and then returning that string. */char *getfullname(char *firstname, char *lastname, int max_len){ char fullname[max_len]; strcpy(fullname, firstname); strcat(fullname, " "); strcat(fullname, lastname); return fullname; }d)#include /* the following code snippet runs through the list of cli arguments entered and displays them to the console. */int main(int argc, char *argv[]){ int i; printf("you've entered the following arguments: "); for(i = 0; i < argc; i++){ print(argv[i]); printf("\n"); } /* */}
Answers: 2
Computers and Technology, 25.06.2019 01:00
Why was it important for the date format to be standardized by the international organization for standardization
Answers: 1
Computers and Technology, 25.06.2019 05:00
Craig keeps missing important staff meetings and getting double-booked for appointments. craig should use scheduling software a database diagramming software a word processor
Answers: 1
Fill in the missing code: this recursive method returns "even" if the length of a give string is ev...
Mathematics, 06.02.2020 02:45
Computers and Technology, 06.02.2020 02:45
Mathematics, 06.02.2020 02:45
Mathematics, 06.02.2020 02:45
Mathematics, 06.02.2020 02:45