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
What are the differences between a cursor, insertion point and mouse pointer?​
Anna35 [415]

Answer:

Explanation:

A cursor is a pointer which indicates the position of the mouse on a computer's display monitor.

An insertion point is a location in a document where additional information is inserted when the user begins to type.

A mouse pointer is an image used to activate/control certain elements in a GUI (graphical user interface).

I know you asked for the differences, though i thought I'd add a similarity. All of these 3 things are similar, as they show where the position of the info/mouse is. :)

Hope this helps!

-Biscuit08

7 0
2 years ago
This is your code.
lubasha [3.4K]

Answer:

35

Explanation:

We will be going inside B array, because he was in second place in array E,and will be the first element of array B, so it's 35

E can be understanded as:

E=[[21, 'dog', 'red'],[35, 'cat', 'blue'],[12, 'fish', 'green']], so, you can see array E as array of arrays or so-called two-dimensional array

6 0
2 years ago
Which file extension takes less storage space?
anyanavicka [17]

I believe the answer would be the JPEG file extension.

4 0
3 years ago
Read 2 more answers
can someone help me write a 5 paragraph essay on microsoft word and why we need and how we use it? if you can please make it sou
DaniilM [7]
Here are some important points:
- we use it to do essays for school
- we can use it to do flyers for recreational events
- we can use it to do pamphlets to inform people
- it is versatile, so you can create many different types of documents
- you can create charts

This can be your opening statement

Today, there is a lot asked of a child in school. From charts to essay to projects, the average kid has at least 10 different programs they use just for one project. But there is one program that came along and changed everything, and that program is called Microsoft word. Microsoft word is valuable because it is versatile (what I wrote earlier about it being able to do many different tasks), it simplifies your experience (what i said about it being able to combine different programs into one), and it is free (you can write about how some programs charge to use their high-grade programs but microsoft is free and avaialabe on every windows
computer.)

GOOD LUCK !
4 0
3 years ago
What Windows utility can enable you to shut down an unresponsive application?
boyakko [2]

Answer:

Task manager

Explanation:

Allows you to force quit applications.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Write the definition of a method named printPowerOfTwoStars that receives a non-negative integer n and prints a string consistin
    10·1 answer
  • Typically, a CLEP exam is taken by students who
    8·1 answer
  • A _____ is a member function that is automatically called when a class object is created.
    13·1 answer
  • When were anonymous inner classes added to java?
    10·1 answer
  • How can I change it to accepted file types: .ppt, .pptx, .xls, .xlsx, .doc, .docx, .zip, .pdf, .accdb, .msg on Inkscape?
    15·2 answers
  • BRAINLYEST IF CORRECT!!! What is the special feature of the View Side by Side command?
    6·2 answers
  • There are a few simple rules that you can follow to store and manage files and folders in your computer. What is the most import
    9·2 answers
  • What does the "zoom tool" do in Photoshop?
    15·2 answers
  • Add Try/Catch error checking To make sure that the user enters valid values in your program. To catch negative values passed to
    9·1 answer
  • What is the primary cause of the industrial revolution?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!