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
olya-2409 [2.1K]
4 years ago
8

Write a complete main method that does the following: 1. Takes any number, but at least two, command line arguments which are nu

mbers (represented as strings) and will print to the console the number of numbers that are evenly divisible by 10. (Hint: loop through the args array) 2. If there are not at least two command line arguments, throw an IllegalArgumentException with an appropriate message.
Computers and Technology
1 answer:
Bess [88]4 years ago
8 0

Answer:

public static void main (String [] args) {

       

   public static void main (String [] args) {

       

       int count = 0;

       int[] arr = new int[args.length];

     if(args.length >=2) {

       for(int i=0; i<args.length; i++) {

           arr[i] = Integer.parseInt(args[i]);

           if(arr[i] % 10 == 0)

                      count++;

        }

     }

   else

        throw new IllegalArgumentException("Missing arguments!");

   

       System.out.println("There are " + count + " numbers that are divisible by 10");

   }

Explanation:

- Create a variable <em>count</em> to hold the count of the numbers divisible by 10

- Initialize an integer array to hold the inputs

- Check the number of arguments that are passed as a parameter. If it is greater than 2, parse the numbers into the <em>arr.</em> Then check the numbers that are divisible by 10, if number satisfies the condition, increment the <em>count </em>by 1.<em> </em>If the length of arguments passed is less than 2, throw an exception

Then:

Print the <em>count</em>

You might be interested in
Question is in photo
Alisiya [41]
Is this java or python pls explain or else i can’t answer
3 0
3 years ago
What is the different between cat and less commands in linux?
luda_lava [24]

the less command is a dedicated file reader while CAT command is mainly used for the creation of files or it can conCATenate (link) files.

5 0
4 years ago
Brad leaves an iPod at Computer Sales &amp; Repair (CSR) to have the battery replaced. CSR sells the iPod to Doris, who does not
katrin2010 [14]
I think the answer is d. I could be wrong.
6 0
4 years ago
) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
Sidana [21]

Explanation:

Some of the most important features needed in a printer are:

  • fast printing speed
  • support wireless connectivity
  • support colored/uncolored printing
  • include improved text quality,
  • improved photo printing capabilities

Based on market prices available on the Amazon website, a printer with the above capabilities start at a price range of <em>at least</em> $80.

4 0
3 years ago
A protocol is:
Setler [38]

Answer:

The answer is: B) a standard set of rules and procedures for control of communications in a network .

Explanation:

To exchange information between computers across a network, there must be a preexisting agreement as to how the information will be structured and how the sender and receiver will behave. Without a protocol, receive or send information, the communication between computers will be impossible. The computer protocol is OSI (Open Systems Interconnection) sets guidelines for implementing networking communications between computers.

8 0
3 years ago
Other questions:
  • A DSLR camera is made up of two parts. They are
    13·2 answers
  • 1. Consider the following code segment.
    8·1 answer
  • What do you need for digital photography?
    14·1 answer
  • Which is a good guideline to follow for adding animation to a presentation?. A. Use a different animation for each slide.. B. Us
    8·2 answers
  • Which of the following is NOT a type of bank?
    12·2 answers
  • Which attribute defines the file name for the specific image in an image tag??
    13·1 answer
  • PLEASEEEE HELPP ILL MARK BRAINLIEST!! in a presentation outline, each slide must represent a main point in the outline. true or
    5·1 answer
  • Using selection sort, how many times longer will sorting a list of 40 elements take compared to a list of 5 elements
    13·1 answer
  • Computer-aided design software can _________________ a. See details that could not be visible with drafting or modeling. B. Simu
    11·1 answer
  • How do I type in bold on brainly?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!