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
Which of the following is not an Error Style for data validation?
Brut [27]

Based on the Microsoft Excel data validation, the option that is not an Error Style for data validation is the <em><u>choice that does not show an error alert.</u></em>

Given that there is no option available, the best way to answer this question is to show the types of Error Styles for data validation available.

<h3>Different types of Error Style for data validation</h3>
  • Stop style: this will bring the option of "Retry, " "Cancel, " and "Help."

  • Warning style: this will show "Continue," with options of "Yes," "No," "Cancel," and "Help."

  • Information Style: this will ask you to input the whole number with the option of "Ok," "Cancel," and "Help."

Hence, in this case, it is concluded that the Error Style for data validation is Stop, Warning, and Information Style.

Learn more about Error Style for data validation here: brainly.com/question/18497347

4 0
1 year ago
Andrew has data in cell E14 and the cell should be blank. Andrew should _____.
denpristay [2]
Use the mouse to click on cell E14 and press delete
4 0
3 years ago
Read 2 more answers
Which technology concept uses computer resources from multiple locations to solve a common problem?
kramer

Answer: Sounds like you are talking about “Distributed memory systems” which use multiple computers to solve a common problem, with computation distributed among the connected computers (nodes) and using message-passing to communicate between the nodes.

8 0
2 years ago
Please help This is a homework in ICT class
Pavlova-9 [17]

Answer:

ejwksjnsskawii28393939393030jedjdjjccjncncnccnnccn

Explanation:

jsskaaaahujpjbhdueiwiwopwpwpwwieuehbfcnnccjxkxooss8ahwhwwnekdodod8djhdmslwoaishwhwkqoq18829293i4644673819191jednsmzljesksowlwlwpwpwnwkpwwwww waaaaayushsjsnmssoss ss sosijw

8 0
2 years ago
What is Gpu in simple terms ​
Bingel [31]
Graphic processing unit !!?????!!??!??!?!!?!!?
5 0
2 years ago
Read 2 more answers
Other questions:
  • What is the function of the keyboard shortcut Ctrl+Shift+E in a word processor
    5·2 answers
  • Which of the following words is an anatomy for cautious
    14·1 answer
  • Web 2.0 has led to a shift just from consuming content towards what
    6·1 answer
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • #Write a function called "replace_all" that accepts three #arguments: # # - target_string, a string in which to search. # - find
    11·1 answer
  • ____ are designed to be used with everyday objects, such as home appliances, gaming consoles, digital cameras, e-readers, digita
    12·1 answer
  • Help me asap please
    15·1 answer
  • What is an aspect ratio?
    6·1 answer
  • Explain how AI smartphone software in the rental car can be a threat to privacy.
    14·1 answer
  • In the year, , the American Department of Defense put a military research network, called ARPANET online.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!