Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The homework is to put several methods in a class file. I dont know how to put all those in a class. Here is the

The homework is to put several methods in a "class" file. I dont know how to put all those in a "class". Here is the instructions.

"1. a method that takes a String and a character as input arguments and returns the number of occurrences of that character in the String.

2. a method that takes two Strings as input arguments and returns the number of occurrences of the second String in the first String.

3. a method that takes an integer number as an argument and returns true if it is a perfect square number. A perfect square is a number that has an integer as its square root. Do not use any of the Math methods to solve this. You may only use the primitive math operators "+, -, /, *, and %".

4. a method that takes an integer number as an argument and returns true it is a prime number. A Prime number is a number that can only be divided evenly by itself and 1. You may only use the primitive math operators "+, -, /, *, and %".

5 a method that takes an integer number as an argument and returns its factorial (x!) value. The factorial (x!) value of a number is that number multiplied by all of the whole numbers in it. 4! = 4 * 3 * 2 * 1. Note: 0! = 1. You may only use the primitive math operators "+, -, /, *, and %".

6. a method that takes a double and an integer as arguments and returns the value of the first raised to the second. You may only use the primitive math operators "+, -, /, *, and %". Note: x^8 = x^3 * x^2 * x^3. For a little extra challenge, you also may want to consider the fact that if the power value is even you can reduce the number of multiplies that need to take place. 3^16 = (((3^2)^2)^2)^2

7. a MyMethods class that contains each of these methods.

8. a testDriver class that calls each of the methods from the MyMethods class."

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

4. Calculate: 3.8 (a) 275-41-25 5.2+1.8 (b) 2.110-15.210 3-61011

Answered: 1 week ago