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

  Declaring a variable using the public, friend, or private

In visual basic.NET, what makes up a component? What are the advantages of components? In addition, what are the types of class data and how do you decide which is appropriate? describe the difference between declaring a variable using the keyword..

  Expalin the file system that will be installed

define the file system that will be installed in the server of your local hospital to support remote access of information by the hospital's doctors while they are using their mobile devices such as cellular phones or PDAs.

  Determine the fraction of heat transferred by radiation

A vertical 1.5-m-high and 3.0-m-wide enclosure consists of two surfaces separated by a 0.4-m air gap at atmospheric pressure.

  Why are executive-level users typically not interested

Why are executive-level users typically not interested or concerned about possible savings to be achieved by personnel reductions made possible by a new system?

  Create a finished template before you generated any of pages

WGD 232- We are going to start by making some changes to our template from last week. Ordinarily, you would create a finished template before you generated any of the pages for your site.

  Create a bar chart showing the average retail price by store

Create a bar chart, showing the average retail price by store. Which store has the highest average? Which has the lowest?

  Determine the capacity of the channel in each case

A Z-channel is a binary-input, binary-output channel, with input and output alphabets x = y = {0,1} and characterized by p ( 011) = E and p (110) = 0.

  What areas of computing will be most important for you

What areas of computing will be most important for you to understand? How would an understanding of computer hardware and software help you in working from home, working with groups in other countries, and contributing your talents?

  Questionwrite down program for a bank account starts out

questionwrite down program for a bank account starts out with user selectable .interest is compounded monthly at user

  Modify the inventory program by adding a button to the gui

modify the inventory program by adding a button to the gui that allows the user to move to the first item the previous

  Create a stockio class that is used to read from a text file

Create a StockIO class that is used to read from and write to a text file using an ArrayList. Make sure to use a delimiter between the fields.

  Write a procedure that will have three parameters-hours

Write a procedure that will have three parameters-Hours, Minutes, and Elapsed_Time-passed to it. Elapsed_Time is an integer number of minutes to be added.

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