Write a java program that first reads a positive integer

Assignment Help Computer Engineering
Reference no: EM132200802

Write a Java program that first reads a positive integer from the user- let's call it howMany. Then the program reads howMany pairs of integers - let's call them n1 and n2.

For each pair, the program determines if the first component in the pair is a multiple of the second component, in other words, if n1 is a multiple of n2.

For example if howMany is 5, your program will read 5 pairs of integers, and for each pair (n1, n2) it will decide if n1 is a multiple of n2.

Sample output:

How many numbers in input? -4
ERROR! Should be positive. REENTER: 5
Enter a pair of positive integers: 10 3
10 is NOT a multiple of 3.

Enter a pair of positive integers: -1 7
ERROR! Both should be positive. REENTER: 15 2
15 is NOT a multiple of 2.

Enter a pair of positive integers: 81 3
81 is a multiple of 3.

Enter a pair of positive integers: 121 11
121 is a multiple of 11.

Enter a pair of positive integers: 12 -7
ERROR! Both should be positive. REENTER: 256 16
256 is a multiple of 16.

Reference no: EM132200802

Questions Cloud

The spherical distance between two points on the surface : Write a Java program that computes the spherical distance between two points on the surface of the Earth, given their latitudes and longitudes.
Group of people in our ist class : Suppose the domain of discourse is the group of people in our IST class, and define the following predicates as follows:
Explain why your truth table shows that the two compound : Explain why your truth table shows that the two compound propositions are or are not logically equivalent.
Describe the scale effect in the scenario : Suppose Oregon proposes indexing the minimum wage to inflation. In the space below, summarize what it would mean to index the minimum wage to inflation.
Write a java program that first reads a positive integer : Write a Java program that first reads a positive integer from the user- let's call it howMany.
Find the average of all the integers in the array : Write a Java program that asks the user to input a positive integer n first, then create an array of size n.
What would be the effect on the skill premium : What would be the effect on the skill premium in the developing country of this income transfer to the RW? (the skill premium is defined as the skilled wage).
Explain the relationship between object and class : a) Explain the relationship between object and class. b) Explain the difference between abstract class and interface.
Calculate the squares and cubes of all integers from 1 to 10 : Write a Java program to calculate the squares and cubes of all integers from 1 to 10. Align the printout as in the sample output.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program that takes an array

Write a program that takes an array containing the digitized representation of a picture of the night sky and locates the stars on it.

  Discuss the convolution

Show by drawing pictures like Fig. that if x(t) = 0 for t 1 and h(t) = 0 for t 2 then the output y(t) = x(t)* h(t) is zero for 1 + T2.

  Investigate the use of web services for the construction

discuss the statement "In the near future, Web application development will be dominated by Web Services, and we can envisage a time when most web application development will involve just the calling of existing Web Services".

  What was the strategic benefit to microsoft of outsourcing

what was the strategic advantage to microsoft of outsourcing xbox production to flextronics?what were the risks

  Tere was a study released in june 2008 by transportation

our response must be 200 words in length for each questions. you are required to use at least your textbook as source

  How does a dual-slope a-d converter work

What is Shannons sampling criterion? How does a successive approximation A/D convener work?

  Describe computer algorithms and its significance

Explain computer algorithms and its significance. Explain some of the technologies that have contributed to the exponential growth of the Internet and the World Wide Web (WWW).

  How are functions and methods different

How are functions and methods different? How is object-oriented programming different from procedural programming?

  Find the 2''s complement of a binary number

Make a circuit which gives the absolute value of a 4-bit binary number. Use four full adders, four multiplexers, and four inverters.

  Enterprising the data mining and data warehousing

Discuss the most proficient ways in which an organization may invest in enterprising the data mining, data warehousing, and the data analytics capabilities.

  Drawbacks of using a web authoring application

Compare the advantages and disadvantages of using the Web authoring application, an HTML editor and a text editor for developing websites.

  Finding the maximum of a finite set of integers

Finding the maximum of a finite set of integers, making use of the fact that the maximum of n integers is the larger of the last integer.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd