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
She thinks it is a good idea to list the gasses bass ed on the the gas found in the atmosphere ...
kramer

Answer:

Answers are Header row options, descending options and the percentage field options.

Explanation:

It is quite clear that text and paragraph options deal with the text, and hence these cannot be used for sorting the gases based on percentage. However, the header row is used, and the descending options and the percentage field options can also be used certainly for the above purpose, and that is to sort the gases based on the percentage. Any of the above three methods can be used, and I am explaining the header row option.

Select in the document all the columns that you want to sort by. And under the paragraph on the home tab, and inside the Data group, click on the sort option. Now you need to decide that you want to sort in ascending order or you want to sort in descending order. And then select the options button (Header Row) in the My list has the area in case the table has a header row. And finally, click Ok. And you are done.

7 0
4 years ago
Why were the spices in Asia so expensive when sold in Europe?
mamaluj [8]
<span>Spices in Asia were so incredibly expensive when sold in Europe because they were new, harder to come by, and had to be imported which was not an easy feat at the time. Importing meant long journeys that were often difficult, and the trades were not always easy.</span>
5 0
3 years ago
Read 2 more answers
What are the differences between switches and routers? cse question
deff fn [24]

Answer:

The main objective of router is to connect various networks simultaneously and it works in network layer

Explanation:

The main objective of router is to connect various networks simultaneously and it works in network layer

7 0
3 years ago
Name the type of software which provides the user interface. [1 mark
Inessa [10]

Explanation:

user interface, also sometimes called a human-computer interface, comprises both hardware and software components. It handles the interaction between the user and the system.

There are different ways of interacting with computer systems which have evolved over the years. There are five main types of user interface:

command line (cli)

graphical user interface (GUI)

menu driven (mdi)

form based (fbi)

natural language (nli)

7 0
3 years ago
Why the computer is known as versatile and diligent device ? explain.<br>​
Scrat [10]

Answer:

Computer is called versatile and diligent device because it is used in almost all the fields for various purposes and it can perform the task repeatedly without loosing its speed and accuracy for long time.

5 0
2 years ago
Other questions:
  • As you move the click and type pointer around the document, the icon changes to represent ____________________ that will be appl
    10·2 answers
  • This provides an easy method for workers to use their computers.
    5·1 answer
  • The advanced boot options screen can be displayed by pressing what key during the boot sequence?
    6·1 answer
  • For what tools such as USMT and Treanxition used?
    15·1 answer
  • Type two statements.
    11·1 answer
  • The IT Department already has been testing Windows Server 2012 R2, and some time ago purchased licenses to convert all of its Wi
    14·1 answer
  • Which of the following choices best completes the above flowchart?
    11·1 answer
  • Your friend gave you a flash drive containing photos from a weekend event. After you copy the files, you notice a bunch of .DS f
    6·1 answer
  • I really need help with this question
    14·1 answer
  • This question involves the creation and use of a spinner to generate random numbers in a game. a gamespinner object represents a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!