Assignment 08- Method_3
Assignment 08- Method_3
Method
9 90
Task 01
[A,B,C,D should be written in a single java file]
A. Write a method called evenChecker that takes an integer number as its
argument and prints whether the number is even or odd inside the method.
evenChecker(17); Odd!!
B. Write a method called isEven that takes an integer number as an argument
and returns boolean true if the number is even otherwise returns boolean
false.
Note: You must call the methods from 1B and 1C, otherwise this task
would be considered invalid.
Task02
[A,B,C should be written in a single java file]
B. Write a method called sphereVolume that takes a double radius in its
parameter and returns the volume of the sphere.
4 3
Note: volume of a sphere is 3
π𝑟
Sample Method Call Sample Output
double volume = sphereVolume(5.0); 523.5987
System.out.println(volume);
C.Write a method called findSpace that takes two values in its parameters one
is an integer diameter and another one is a String. Using the given diameter,
this method should calculate the Area of a circle or the Volume of a sphere
depending on the value of the second parameter. Finally, it should print the
result inside the method.
Note: You must call the method written in task 2A & 2B, otherwise this
task would be considered invalid.
findSpace(5,"sphere"); 65.4498
Task03
[A,B should be written in a single java file]
B. Write a method called triArea that takes 3 sides of a triangle as 3 integer
arguments. The method should calculate and print the area of the triangle
only if it's a valid triangle otherwise print that it's not a valid triangle.
Area of triangle = √[s(s−a)(s−b)(s−c)], where 's' is the semi perimeter of the
triangle. So, semi-perimeter = s = perimeter/2 = (a + b + c)/2.
Note: You must call the method written in task 3A, otherwise this task
would be considered invalid.
Task04
[A,B,C should be written in a single java file]
C.Write a method called special_sum that calculates the sum of all numbers
that are either prime numbers or perfect up till the integer value given in its
parameter. This integer value must be taken as user input and passed into the
method.
Note: You must call the methods written in task 4A & 4B, otherwise this
task will be considered invalid.
showDots(3); …
show_palindrome(3) 12321
..1..
.121.
showDiamond(3) 12321
.121.
..1..
Task06
[A,B should be written in a single java file]
A.Write a method called calcTax that takes 2 arguments which are your age
then your salary. The method must calculate and return the tax as per the
following conditions:
Note: You must call the method written in task 6A, otherwise this task
would be considered invalid.