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]
2 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]2 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
The Earth's _______ is ductile overall, tending to flow very slowly and deform in a _______ manner.
kipiarov [429]

<span>The asthenosphere is a part of the upper mantle just below the </span>lithosphere<span> <span>that is involved in </span></span>plate tectonic movement<span> <span>and </span></span>isostatic<span> <span>adjustments. The lithosphere-asthenosphere boundary is conventionally taken at the 1300 °C </span></span>isotherm<span>, above which the mantle behaves in a rigid fashion and below which it behaves in a </span>ductile<span> fashion. a</span><span>nd </span>flows very slowly, in a manner<span> similar to the ice at a bottom of a glacier.</span>

5 0
3 years ago
Read 2 more answers
. Why is it important to use Social Media responsibly? ANSWER NOW!!!
Alenkinab [10]

Answer:

Why is social media important? Social media is important because it allows you to reach, nurture, and engage with your target audience — no matter their location. When a business can use social media to connect with its audience, it can use social media to generate brand awareness, leads, sales, and revenue.

5 0
2 years ago
Read 2 more answers
Explain the need for data structures when developing software.
Sergio [31]

Solution:

It is  important because, it has to do operation on so without, data structures and algorithms.

It performs these operation:  

 1)Take an input

2) Process it  

3) Give back the output.

The input can be in any form, for ex while searching for directions on google maps,  the starting point and the destination as input to google maps, while logging in to any social sites, We have to give our email and password as input and so on.

Similarly, in the third step, the computer application gives us output in some form or the other.

To make this process efficient, we need to optimize all the three steps.

4 0
3 years ago
Darnell is preparing to read A Rocket to the Stars for class. What might he predict based on the title?
liq [111]

Answer:

It is science fiction

Explanation:

Rockets and stars relate to science

8 0
3 years ago
Read 2 more answers
Elizabeth has an assignment to complete. in her internet search, she got 5,006,321 hits. to narrow the search, she would convert
ivolga24 [154]
In order to narrow the search and get more precise and more efficient Internet research, Elizabeth should use unique and specific terms, should not use common words, she could use some search engines also (Exploratium, Teoma,...) ..., use different search engines search engines, like Yahoo!, Bing, Startpage, or Lycos.
6 0
2 years ago
Read 2 more answers
Other questions:
  • what is the restaurant with the black pom tree and yellow backround three letter name from hi guess the restaurant
    14·2 answers
  • Why is it a mistake to put e-mail address of people who don't know each other in the "to:" field
    9·2 answers
  • The most common solution to supply chain uncertainties is to build inventories or __________ as insurance.
    6·1 answer
  • The computer component that makes sure that instructions are decoded and executed properly is the ___________.
    11·2 answers
  • Write a method called all Less that accepts two arrays of integers and returns true if each element in the first array is less t
    12·1 answer
  • There are several reasons it’s important to use the right tool and the right size tool for the job, but the most important reaso
    8·1 answer
  • What is the TAG to begin a Web page, as recommended by the W3C?
    13·1 answer
  • A technician has been given a PC that is not powering up. After brief troubleshooting, the technician comes to the conclusion th
    14·1 answer
  • A line beginning with a # will be transmitted to the programmer’s social media feed.
    11·2 answers
  • A(n) __________ prevents outsiders from accessing corporate information the user does not want others to see.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!