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
Kobotan [32]
4 years ago
8

Write a method isMultiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The me

thod should take two integer arguments and return 1 if the second is a multiple of the first and 0 otherwise.
Computers and Technology
2 answers:
SVEN [57.7K]4 years ago
8 0

Answer:

See the explanation

Explanation:

Given to integers a,b we can find integers k,r such that a = kb +r, where r is called the residue, where |r|<|b|. When r = 0, we say that a is a multiple of b. Based on that, we define the function %(a,b) which gives out the residue between a,b. For example %(4,3) =1 since 4 = 1*3 +1.

The main idea of the program should be: if the residue is 0, then they are multiples and it should return 1, otherwise, return 0.

Let us use the following syntaxis function name (parameter 1, parameter 2).

So, we have

isMultiple(a,b) {

if %(a,b)=0 (this means they are multiples)

then return 1

else return 0

end

}

NNADVOKAT [17]4 years ago
3 0
I don't know what language you want it in but I will write this in Java.

public int isMultiple(int x, int y) {
    if (x % y == 0)
        return 1;
    return 0;
}

The mod function (%) returns 0 iff x divides y.
Feel free to ask me questions!
You might be interested in
Write a program to take in a time-of-day on the command-line as 3 integers representing hours, minutes, and seconds, along with
nexus9112 [7]

Answer:

In Python:

hh = int(input("Hour: ")) * 3600

mm = int(input("Minutes: ")) * 60

ss = int(input("Seconds: "))

seconds = int(input("Additional Seconds: "))

time = hh+ mm + ss + seconds

hh =  int(time/3600)

time = time - hh * 3600

mm = int(time/60)

ss = time - mm * 60

while(hh>24):

   hh = hh - 24

print(str(hh)+" : "+str(mm)+" : "+str(ss))

Explanation:

We start by getting the time of the day. This is done using the next three lines

<em>hh = int(input("Hour: ")) * 3600</em>

<em>mm = int(input("Minutes: ")) * 60</em>

<em>ss = int(input("Seconds: ")) </em>

Then, we get the additional seconds

<em>seconds = int(input("Additional Seconds: "))</em>

The new time is then calculated (in seconds)

<em>time = hh+ mm + ss + seconds</em>

This line extracts the hours from the calculated time (in seconds)

hh =  int(time/3600)

time = time - hh * 3600

This line extracts the minutes from the calculated time (in seconds)

mm = int(time/60)

This line gets the remaining seconds

ss = time - mm * 60

The following iteration ensures that the hour is less than 24

while(hh>24):

   hh = hh - 24

This prints the calculated time

print(str(hh)+" : "+str(mm)+" : "+str(ss))

6 0
3 years ago
All of the following are guidelines for maintaining an engineering notebook EXCEPT
gayaneshka [121]

C) numbering pages at the bottom inside corner

An Engineering notebook is a legal document made of bound, grid paper where engineers formally document written ideas, sketches, work session summaries, research findings and interview information in chronological order.

When not in use, the notebook should be stored in a safe location with each page dated and signed.

There will absolutely no situation where a page is removed.

All entries should start at the top of each page and ending at the bottom. Supporting material should be permanently affixed.  

Book pages should be numbered on the top right side of the page.  


6 0
3 years ago
The total cost of a DUI could be as high as----- dollars?<br> a100<br> b500<br> c1000<br> d8000
Svet_ta [14]
the answer is d because depending on your state's laws they can also and endangerment of self and others 
7 0
4 years ago
Read 2 more answers
Write any two reasons why files are stored in folders​
iogann1982 [59]

Answer:

Explanation:

The answer is The tree structure suggests the main benefit of folders: to organize your files. You can create folders to store and organize your pictures, your documents, your videos, and so on. Folders are also used to separate the files created by different users.

4 0
3 years ago
Read 2 more answers
What is one pass of a coding sequence called?​
Romashka-Z-Leto [24]

One pass code is final version of executable file for end user with zero error. While compile the software it give Error it give the list of error to end user further to address the issue.

<u>Explanation:</u>

In computer pass of a code is used in compiler mode of programing languages. Normally end user after completing the software development he or she will compile the software programs.

So as result compiler will  pass code in multiple sequence and make the software as executable file as standalone or execute file which executable software can understanding language.

3 0
3 years ago
Read 2 more answers
Other questions:
  • ____ software consists of the operating system and utility programs that control a computer system and allow you to use your com
    9·1 answer
  • Which of the following is a valid SQL statement? a. c.customer#, order#, orderdate, shipdate FROM customers c NATURAL JOIN order
    13·1 answer
  • The __ contains the computers “brain,” the central processing unit (cpu)
    9·1 answer
  • What is a quasi vpn?
    14·1 answer
  • Which of the following is a separate summary worksheet in the same workbook?
    14·1 answer
  • C. There are two types of computer on the basis of size. true or false​
    5·1 answer
  • Nobody mind this plz
    14·1 answer
  • Answer for 3 and 4 please
    15·2 answers
  • Name the major types of computer systems from slowest to fastest. ​
    9·1 answer
  • A market-product strategy that requires no change in the basic product but instead seeks new buyers is known as ______
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!