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
yarga [219]
3 years ago
10

Write the Number class that can be used to test if the number is odd, even, and perfect. A perfect number is any number that is

equal to the sum of its divisors. Write the NumberAnalyzer class that has an ArrayList of Number to determine how many numbers in the list are odd, even, and perfect.
Computers and Technology
1 answer:
egoroff_w [7]3 years ago
6 0

Answer:

Explanation:

The following code is written in Python. It creates a class that takes in one ArrayList parameter and loops through it and calls two functions that check if the numbers are Perfect, Odd, or Even. Then it goes counting each and printing the final results to the screen.

class NumberAnalyzer:

   def __init__(self, myArray):

       perfect = 0

       odd = 0

       even = 0

       for element in myArray:

           if self.isPerfect(element) == True:

               perfect += 1

           else:

               if self.isEven(element) == True:

                   even += 1

               else:

                   odd += 1

       print("# of Perfect elements: " + str(perfect))

       print("# of Even elements: " + str(even))

       print("# of Odd elements: " + str(odd))

   def isPerfect(self, number):

       sum = 1

       i = 2

       while i * i <= number:

           if number % i == 0:

               sum = sum + i + number / i

           i += 1

       if number == sum:

           return True

       else:

           return False

   def isEven(self, number):

       if (number % 2) == 0:

           return True

       else:

           return False

You might be interested in
So what do I do if it doesn't take me to the sign up page? I
vesna_86 [32]

Answer:

Try to restart the computer or something.

Explanation:

8 0
3 years ago
Create an algorithm and flowchart that will accept name of user and display it.
vivado [14]

Answer:

Algorithm

1.Start.

2.Using an input function, ask the user to input the name and store the Entered Value in string    variable.

3.Print value stored in String Variable.

4.End.

Flow chart:

5 0
4 years ago
If you need to multiply 50 and 8 and divide by 2, what would you type on the numerlc keypad?
nata0808 [166]

Answer:

50*8/2

The asterisk is the multiplication sign and the parenthesis is the division.

I've never used an apostrophe for a multiplication sign before, but I'm guessing multiplication is what it stands for.

Explanation:

4 0
3 years ago
_____ are pictures that you can click on to tell your computer what to do.
KatRina [158]

Answer:icons

Explanation:The reason it is icons is because icons can become pictures

4 0
3 years ago
Ms. Osteen gives her class an assignment to insert background color that gradually changes from blue to green. To accomplish thi
irina1246 [14]

Answer:

C

Explanation:

7 0
3 years ago
Other questions:
  • What happens to the data in rom when the power is turned off?
    10·1 answer
  • Some personal computer manufacturers provide a hard disk configuration that connects multiple smaller disks into a single unit t
    6·1 answer
  • HELP PLZ ;(
    10·2 answers
  • The qwerty keyboard is the most common layout of keys on a keyboard.
    5·2 answers
  • A thesaurus can be used to look up a (n) or word similar in meaning to a given word
    15·1 answer
  • COMPUTER FUNDIMENTAL HELP 20 POINTS!!!
    5·1 answer
  • You have a network of ten computers connected to a single switch that has 12 ports. You need to add six more computers to the ne
    12·1 answer
  • This is just for the points
    15·2 answers
  • I have no idea what I’m doing and this is due in 45 minutes
    7·1 answer
  • What makes a source credible?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!