Question: ASSIGNMENT 3 1. Write a class named QuestionA including the following methods: (60 points) two global variables (named gvar1 and gvar2), both of which are
ASSIGNMENT 3
1. Write a class named QuestionA including the following methods: (60 points)
two global variables (named gvar1 and gvar2), both of which are instance variables and integers.
one static variable (named PI), the data type of which is double and the value of which is 3.14159.
an instance method named funA which has two parameters and a return statement. The data type of each parameters is integer. The method returns the sum of two parameters in its return statement.
an instance method named funB which has two parameters and a return statement. The data type of each parameters is double. The method will return the sum of two parameters in its return statement.
an instance method named funC which has one parameter named psum and has no return statement. The data type of the parameter is integer. The method calculates the sum of two gvar1 and gvar2 and then assigns the sum to the parameter psum. Finally, the method prints the value of psum.
a static function named funD which has one parameter named radius and a return statement. The data type of the parameters is integer. The function returns the area of a circle based on the formula: PI*radius*radius.
a main method that will call all methods/functions above. When calling funA, it will use pass-by-value. When calling funB, it will use pass-by-reference. When calling funC, it will use pass-by-out-parameter. When calling funD, it will use pass-by-value.
2. Write a class named QuestionB that only has a main method. In the main method, it will call all methods/functions in the class QuestionA. (40 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
