1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Svetlanka [38]
2 years ago
8

Write a public static method named evens that takes in 1 argument int a, and returns a String containing all positive even numbe

rs with each separated by a comma from O up to that number inclusive if it is also even
Remember if the argument is odd not to include it in the output
Remember there should be no trailing comma after the values
If the argument a is negative return a String that says "NONE!
(Do not print the String)
Example evens(5) String returned by method. 0.2.4
Example evens(8) String returned by method. 0.2.4,6,8
Example evens (9) String returned by method 0.246,8
Example evens(-5), String returned by method: NONE
Example evens(O) String retumed by method 0
Example evens(1) String returned by method 0
Computers and Technology
1 answer:
topjm [15]2 years ago
4 0

public class JavaApplication48 {

   public static String evens(int a){

       String txt = "";

       if (a < 0){

           return "NONE!";

       }

       else if(a%2 == 1){

           a -= 1;

       }

       for (int i = 0; i <= a; i+=2){

           if (i < a){

               txt += i+",";

                       }

           else{

               txt += i;

           }

       }

       return txt;

   }

   public static void main(String[] args) {

       System.out.println(evens(1));

   }

   

}

I hope this helps!

You might be interested in
You are building a gaming computer and you want to install a dedicated graphics card that has a fast GPU and 1GB of memory onboa
Vilka [71]

Answer:

a. PCI express

Explanation:

<em>PCI express</em> (Peripheral Component Interconnect Express) is a high speed serial bus and commonly used motherboard interface for  Graphics card, wifi, SSDs and HDs hardware connections. Simple PCI can also be used but PCI express has more error detection accuracy lesser number of I/O pins and better throughput as compared to simple PCI.

6 0
3 years ago
what is a tool or electrical system means intentionally creating a low-resistance path that connects to the earth
nikklg [1K]
A comper??><>?????????????????????????????????????
7 0
3 years ago
Which camera does Angelina use?
julia-pushkina [17]

Answer:

mirrorless cameras have lot more space due to not having mirrors. and they have the same or better quality than DSLR's.

8 0
3 years ago
The binary search algorithm cannot be used to search an array that is not sorted does twice as much work as sequential search on
maks197457 [2]

Answer:

Option A => cannot be used to search an array that is not sorted

Explanation:

The reason for choosing ‘option a’ is that, the actual working mechanism of binary search is to sort the array first then choose a middle element and compare the given search element with the help of middle element. Let us deeply understand how this sorting and choosing middle element does the work of search.

So this middle element is the key pointer which tells the system that the matching element might be present either to the list of values which are less than middle element or it would be present in the right side / greater than middle element. So, it would search only in the list satisfying the middle element. So it is always necessary to sort the element.

4 0
3 years ago
How does an author use artifacts in literature?
cestrela7 [59]
They use artifacts in l<span>iterature in order to develop the plot and the characters.</span>
7 0
3 years ago
Other questions:
  • Web pages often have built-in connections, or links, to other documents, graphics, other web pages, or web sites. true or false?
    9·1 answer
  • A​ _______ helps us understand the nature of the distribution of a data set.
    10·1 answer
  • A port is the point at which a peripheral device attaches to or communicates with a computer or mobile device. True False
    15·1 answer
  • Anyone know the answer I need help
    12·1 answer
  • Give a detailed example of how an app (that you use regularly)uses parameters. You must state the app's name and function, the p
    7·1 answer
  • Write a program that estimates how many years, months, weeks, days, and hours have gone by since Jan 1 1970 by calculations with
    15·1 answer
  • A term to describe articles that can be displayed in their entirety,as opposed to abstract and references only
    11·1 answer
  • Can someone please give me the 3.6 code practice answer I will mark you brainlyist
    13·1 answer
  • Which is the correct option?
    6·1 answer
  • Which of the following screen elements is a horizontal bar that displays at the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!