Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help Comments Header a Footer 8. (3 points; 1 points each) Give the signa

ID: 3850503 • Letter: P

Question

please help

Comments Header a Footer 8. (3 points; 1 points each) Give the signature for a method that can be used to accomplish each of these tasks. Do not write the full method, only give the signature. h. A method that returns the maximum of two numbers. For example, if it was given 3 and 5, it would return 5. i. A method that returns the numbers of times a specific character appears in a word- given the character and the word. For example, i this method was given "sarah" and "s', it would return 1. j. A method that prints an alphabetically sorted version of a string For example, if given "sarah" it "aahrs" to the screen and return nothing.

Explanation / Answer

Question1) : A method that returns the maximum of two numbers.Foe Example,if it was 3 and 5,it would return 5

Answer:   

Signature method :   Math.max(3, 5);
Ex: var a = Math.max(5, 10);


// max example
#include <iostream> // std::cout
#include <algorithm> // std::max

int main ()
{

std::cout << "max()==" << std::max(3,5) << ' ';
  
return 0;
}

Question 2) :A method that returns the numbers of times a specific character appears ina aword.given the charater and the word.
for example,if this method was given "sarah" and s,it would return 1

Answer:
Signature Method: str=count(element)    // Here element = digit you want to check

Ex:count = str.count('s')

Input string: str = Happybirthday
Construct character count array from the input string.

...
str.count['b'] = 1
str.count['h'] = 2
str. count['p'] = 2
str. count['t'] = 1

Question 3) :A method that prints an alphabetically sorted version of a string.For example,if given "sarah" it would print "aahrs" to the screen and return nothing.
Answer:

Signature Method : Arrays.sort(sarah);

the output will be : aahrs


import java.util.Arrays;

...
Arrays.sort (int [])
Arrays.sort (String [])
Arrays.sort (float [])
Arrays.sort (double [])
Arrays.sort (long [])
Arrays.sort (Object [])
...