Question
Submission instructions: The following methods can be written and tested in one program. Use Java Note: To receive full credit, each method should be tested
Submission instructions: The following methods can be written and tested in one program. Use Java
Note: To receive full credit, each method should be tested with at least TWO different method calls. Unless the directions specify, do not include input or output in your methods!
1. Write and test the following method that calculates and returns the area of a triangle.
float triangleArea(float, float);
Triangle area is given by A = 0.5bh where b is the base and h is the height of the triangle.
2. Write and test the following method that determines whether a given number is even. If it is even, return true, if it is odd, return false.
bool isEven(int);
3. Write and test the following method that accepts two integer parameters, i and j, and then returns the sum of the numbers from i to j.
int sum(int, int);
4. Write and test the following method that determines accepts an integer value n and returns the sum of the first n natural numbers. int sumN(int);
5. Write and test the following method that accepts an integer value n and displays n lines of 5 stars each.
void printNLines(int);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started