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]
3 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]3 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
Rheneas wants to ensure his management team is aware of the common causes for failed enterprise system implementations before th
Vaselesa [24]

Rheneas will inform to the team that (c) the failure rate for ERP implementations worldwide is 21 percent.

<h3>Definition of ERP?</h3>

ERP or Enterprise Resource Planning is a software which organizations use to manage business activities, for example: accounting, risk management and compliance,  procurement, project management, and supply chain operations. ERP core is to automate the internal business process on the organisazations by drawing central database and control the process based on input from the organisazation divisions. There is five main component on the ERP as follow:

  1. Finance
  2. Supply Chain Management (SCM)
  3. Customer Relationship Management (CRM)
  4. Human Resources (HR)
  5. Manufacturing and logistics

Learn more about ERP at brainly.com/question/29426906

#SPJ4

4 0
1 year ago
How do you know if a remote host is alive or not?
-BARSIC- [3]

Answer:

ing is the way to test whether a host is alive and connected. (If a host is alive but disconnected or slow to respond, you can't distinguish that from its being dead.) Options supported by the ping command vary from system to system

Explanation:

5 0
3 years ago
ven int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 5
monitta

Answer:

Following are statement is given below

int  k=1,total=0; // variable declaration

while(k<50) // iterating the while loop

{

   total=total+k*k;//  calculating the square

   k=k+1; // increments the value of k by 1    

}

Explanation:

Following are the description of Statement.

  • Declared a variable "total" and "k" of the "integer " type initialized the total to 0 and "k" to 1.
  • Iterating the while loop for less then 50 .In this loop, we calculating the sum of square of first 50 number in the "total" variable .
  • After that increment the value of "k" variable by 1 to execute the loop less then 50 .

3 0
3 years ago
Lab 2: UDP Pinger Lab In this lab, you will learn the basics of socket programming for UDP in Python. You will learn how to send
Alex17521 [72]

Answer:

huhhuikkkkkkkkkkkkkkkkkkkkkkkkkkkk

8 0
3 years ago
Help me pls...
den301095 [7]

Answer:

None

Explanation:

A cell is a living thing it contains a plasma membrane, an outer covering that separates the cell’s interior from its surrounding environment; cytoplasm, consisting of a jelly-like region within the cell in which other cellular components are found; DNA, the genetic material of the cell; and  ribosomes, particles that synthesize proteins

6 0
3 years ago
Read 2 more answers
Other questions:
  • After Intel faced strong shifts in technologies, such as cloud services, social networking, mobile devices, etc., Intel realized
    11·1 answer
  • A(n) ______ is an output device that visually conveys text, graphics, and video information.
    5·1 answer
  • Assign testResult with 1 if either geneticMarkerA is 1 or geneticMarkerB is 1. If geneticMarkerA and geneticMarkerB are both 1,
    11·1 answer
  • Write a program to read 2 numbers and display the largest of the two. You should use scanfto read the two numbers and use if sta
    8·1 answer
  • Heelo how do u do python syntax lesson 11 on code academy
    12·1 answer
  • A software program installed without the user's knowledge and designed to alter the way a computer operates or to cause harm to
    12·1 answer
  • What is the purpose of the transport layer in managing the transportation of data in end-to-end communication? Explain how it sh
    12·1 answer
  • What is computer graphics uses of computer graphics​
    14·1 answer
  • 1. Do our shared social experiences lead us to think<br><br> communication is a cure-all?
    13·1 answer
  • How to follow accounts on brainy
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!