Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Submission instructions: The following methods can be written and tested in one program. Note: To receive full credit, each method should be tested with at

Submission instructions: The following methods can be written and tested in one program.

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

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

Step: 3

blur-text-image

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

List 6 things that an Incident Command Post ( ICP ) should provide?

Answered: 1 week ago

Question

=+Where do you want to live and work?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago