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

  Design the circuit using one rotate-right circuit

Design the circuit using one rotate-right circuit, one rotate-left circuit, and one 2-to-1 multiplexer to select the desired result. Derive the code.

  Describe the concept of first-come first-serve basis

Persons arrive at a Xerox machine according to a Poisson process with rate one per minute. The number of copies to be made by each person is uniformly.

  Why the performance is poorer than only running simulation

A student ran numerical simulation on a dual-core computer (3.2 GHz, 2MB Smartcache, 32GB RAM).

  Write down some of the benefits that cascading style sheets

what are two site examples that have images or multimedia that are used effectively on the site? why do you think they

  Create a file-system-based timeline

Create a file-system-based timeline and turn in the first 10 and last 10 entries as well as the hash value of the file

  Determine all possible total orders of transactions

Let objects x and y be stored at site 1, and objects z and w be stored at site 2. Determine, for each of the following executions, whether the execution is serializable or not.

  Write a program to determine and output to the screen

Write a program to determine, and output to the screen, the class of an earthquake, given its magnitude.

  Design a tm m that converts digits from unary representation

Design a TM M that converts digits from unary representation to decimal.

  Simplify the circuit using four k-maps

Design a minimum circuit to convert a BCD number to an excess-3 number. That is, the circuit will have four inputs and four outputs. Use four K-maps.

  What is the syntactic form of an el expression

What is the syntactic form of an EL expression? What are the two ways the param implicit variable can be used to access form values?

  Display the left justified output on two seven segment

Write and execute an assembly code that takes analog input of 2V at channel 1 of the ADC at the Fosc/16.

  Question 1 we know that telecommunications law has existed

question 1 we know that telecommunications law has existed as systems were first developed to carry communications over

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