Write a method evens that accepts an integer parameter n and that returns the in
ID: 3657168 • Letter: W
Question
Write a method evens that accepts an integer parameter n and that returns the integer formed by removing the odd digits from n. The following table shows several calls and their expected return values: Call Valued Returned evens(8342116); 8426 evens(4109); 40 evens(8); 8 evens(-34512); -42 evens(-163505); -60 evens(3052); 2 evens(7010496); 46 evens(35179); 0 evens(5307); 0 evens(7); 0 If a negative number with even digits other than 0 is passed to the method, the result should also be negative, as shown above when -34512 is passed. Leading zeros in the result should be ignored and if there are no even digits other than 0 in the number, the method should return 0, as shown in the last three outputs.Explanation / Answer
Does it have to be done recursively? (as above?) When you say it needs to be 2n long I am assuming you mean 2n long, and so I just add two asterisks each time. if not: public static String starString(int n){ String s = ""; for(int 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.