Dicussion questions Solution Solution

1.
Provide Java code for a method that would perform functionality of your choice. Try to create functionality that is unique - something that you could use. Be sure to include an example call to your method and explain the code you developed.
Demonstrate your code functions properly.

2.
Discuss about the benefit of using a method. How do you define a method? How do you invoke a method?
How is an argument passed in a method? Can the argument have the same name as its parameter?
What is method overloading? It is permissible to define two methods that have the same name but different parameter types?

3.
Let’s design and implement some methods to exercises the methods
a) Provide Java code for a method that would calculate the perimeter of a rectangle. Be sure to include an example call to your method and explain the code you developed. The program prompts the user to enter the width and height of the rectangle.
b) Provide Java code for a method that would convert Fahrenheit to Celsius. Be sure to include an example call to your method and explain the code you developed. Use formula C=(F-32)*5/9

Powered by