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
If you created a variable called name, what data type would that value be? Group of answer choices a float a string a Boolean an
Semenov [28]

I think its an integer

8 0
2 years ago
Read 2 more answers
The user cannot use a computer system without.................... software<br><br>​
zheka24 [161]

Answer:

the user cannot use a computer system without hardware and software

4 0
3 years ago
Read 2 more answers
Why is the radial gradient type a good choice for the grapes?
Grace [21]
<span>when you use the radial gradient fill it gives it a look like a shine on them. </span>
3 0
3 years ago
Read 2 more answers
Which of the following protocols is used by Web servers to establish communication between a web page and a web browser?
Iteru [2.4K]
HTTP or HTTPS is most likely the answer you are looking for.
6 0
3 years ago
This question refers to a standard deck of playing cards. If you are unfamiliar with playing cards, there is an explanation in P
Norma-Jean [14]

Answer:

Explanation:

Number of ways to select 10 girls in 35C₁₀

Number of ways to select 10 boys in 35C₁₀

Total Number of ways to select is 35C₁₀ x 35C₁₀

4 0
3 years ago
Read 2 more answers
Other questions:
  • The unique global address for a web page or other resource on the internet is called the ________.
    7·1 answer
  • Some of the more important __________ include anti-virus (and anti-malware), host-based firewall, system hardening (removing unw
    11·1 answer
  • A simulation model includes: a. a description of the components of the system. b. a simulation clock. c. a definition of the sta
    8·1 answer
  • MICR is an input or output devices
    5·1 answer
  • Exercise 4: Bring in program grades.cpp and grades.txt from the Lab 10 folder. Fill in the code in bold so that the data is prop
    12·1 answer
  • Explain why interrupt times and dispatch delays must be limited to a hard real-time system?
    8·1 answer
  • PLEASE HELP ME I WILL GIVE BRAINIEST AND 40 POINTSPython Project Worksheet
    12·1 answer
  • Write a C program that right shifts an integer variable 4 bits. The program should print the integer in bits before and after th
    15·1 answer
  • What<br>are<br>the features of secondary storage media​
    13·2 answers
  • 7.4 Lesson Practice (projectstem): what is output if the user is enters 2?​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!