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
Which operation is not efficiently supported by heaps?
vodka [1.7K]

In the case above, the operation is not efficiently supported by heaps is Find.

<h3>What are heap operations?</h3>

The operation that are known to often use heaps are:

  • Heapify
  • Find-max (or Find-min)
  • Insertion, etc.

Therefore, In the case above, the operation is not efficiently supported by heaps is Find.

See full question below

Which operation is not efficiently supported by heaps?

a. DeleteMin

b. Find

c. FindMin

d. Insert

e. all of the above are sufficiently supported

Learn more about operation from

brainly.com/question/24214198

#SPJ11

6 0
2 years ago
Python program: Develop a program that will keep track of inventory for a local retail store. Fortunately, the store only offers
EastWind [94]
333 Sweater 500 The better programs will only process data
7 0
3 years ago
Read 2 more answers
Jason is working on a Microsoft Excel worksheet and he wants to create a Print Preview shortcut. His teacher asks him to access
EastWind [94]

Answer:

New Tab (Custom) and New Group (Custom)

Explanation:

In order to accomplish this Jason needs to use New Tab (Custom) and New Group (Custom). The New Tab (Custom) will allow Jason to add a new tab with the Print Preview shortcut as a brand new tab in the software. Then using the New Group (Custom) tab, Jason can group the Print Preview shortcut with the worksheet toolbar so that it appears as part of the original toolbar with the rest of the tools available in the toolbar.

5 0
3 years ago
Which type of operating system is usually used in personal computers
velikii [3]

The most common operating system for personal computers is Windows.

7 0
3 years ago
This is a bit confusing to me. Could someone please help me! I have to use CSS to Design a Web Page. I will mark Brainliest!
GrogVix [38]

Answer:

CSS is easy

Explanation:

CSS is like the color or your sylte for a webpage.

6 0
3 years ago
Other questions:
  • Write a program that can be used to gather statistical data about the number of movies college students see in a month. The prog
    11·1 answer
  • How is typing speed measured
    12·2 answers
  • Suppose your SOHO network connects to the Internet using cable modem. When you open your browser and try to access a web site, y
    8·1 answer
  • There are many different types of decision-making. Which of the following is NOT a type of decision-making? a. fiat rule b. sing
    15·2 answers
  • Define networks, marketplaces, and platforms and discuss their differences.
    15·1 answer
  • A program called a ( n ) ____ translates instructions written in high-level languages into machine code.
    13·1 answer
  • Given the business rule "an employee may have many degrees," discuss its effect on attributes, entities, and relationships. (Hin
    10·1 answer
  • Public relations strives to foster goodwill between a client and a audience ​
    8·1 answer
  • Which of the following is a table which can be rearranged to analyze data in a variety of ways?
    13·1 answer
  • A Consider the following method definition. The method printAllCharacters is intended to print out every character in str, start
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!