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
Which media player is designed to transfer media to an iOS device?
zubka84 [21]
C. Itunes.
In Apple devices, the iTunes if the only application may it be Windows or OSX operating system iTunes is the only official app registered by apple to stream via cable or wifi to the devices like iPhone, iPad and other Apple devices.

A. Streaming
Slightly the same with downloading but stream makes it self available as it download its content over the internet.
8 0
4 years ago
A red wavy line under a word means _____.
zhenek [66]
The third option is correct.
3 0
3 years ago
Read 2 more answers
A programmer is responsible for solving a problem and making a presentation that includes his solution. He does not have much ro
sashaice [31]

Probably 2 but that's just a guess.


5 0
3 years ago
Read 2 more answers
How is science and technology used in the society​
Molodets [167]

Answer: science and technology

Explanation:

The essence of how science and technology contributes to society is the creation of new knowledge, and then utilization of that knowledge to boost the prosperity of human lives.

4 0
3 years ago
Which statement did john dalton make about atoms?
Wewaii [24]
D. He said atoms are indivisible and indestructible.
4 0
4 years ago
Read 2 more answers
Other questions:
  • In your opinion, what is the best practice for organizing files within your computer?
    15·2 answers
  • You have been found at fault in a crash where someone was injured and was transported to a medical treatment facility. By law yo
    15·2 answers
  • In 1948, a Bell Labs researcher named Claude Shannon wrote a technical report in which he proposed that all information media co
    11·1 answer
  • A acrostic sentence for mutualism?
    10·1 answer
  • A legend in Excel is __________.
    10·2 answers
  • Lin is booting up his computer, and during the boot process, the computer powers down. After several unsuccessful attempts to bo
    12·1 answer
  • The use of an information system to support the sharing of content among networks of users related by common interests is termed
    10·1 answer
  • Construct a formula in cell D11 to calculate the sales tax amount for transaction 578. Be sure to appropriately reference the tr
    8·1 answer
  • Which of these is true about moores law
    6·1 answer
  • Select the correct answer
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!