Assignment on Method4
[Non-void Method with Parameters]
1. Write a Java program using a method called long square(int n) to find the Square of any number.
2. Write a Java program using a method called long product(int n1, int n2) and double average(float n1, float n2) to find the Product and Average of two numbers.
3. Write a Java program using a method called int area(int l int b), int perimeter(int l int b) to find the Area and Perimeter of Rectangle.
4. Write a Java program using a method called float simpleInterest(float p, float r, float t) to find the Simple Interest.
5. Write a Java program using a method called long factorial(int n) and int sumOfSeries(int n) to print the Factorial /Sum of Series S=1+2+3+.... +n.
6. Write a Java program using a method called int greatestDigit(int n), int smallestDigit(int n) to accept a number from user and find the greatest and smallest digit.
7. Write a Java program using a method called boolean specialTwoDigit(int n) to find the special two-digit number is such that when the sum of the digits is added to the product of its digits, the result is equal to the original two-digit number.
Example:
Consider the number 59.
Sum of digits = 5+9=14
Product of its digits = 5 x 9 = 45
Sum of the digits and product of digits = 14 + 45 = 59
8. Write a Java program using a method called int dudeney(int n) to check whether the number is a Dudeney number, a number is Dudeney if the cube of the sum of the digits is equal to the number itself.
Eg : 512
=(5+1+2)3 = (8)3 =512
9. Write a Java program using a method called boolean markNumber(int n) to check whether the number is a Mark number or not. A number is said to be Mark when sum of the squares of each digit is an even number as well as the last digit of the sum and the last digit of the number given is same.
Example: n = 246
sum = 2 x 2 + 4 x 4 + 6 x 6 = 56
56 is an even number as well as last digit is 6 for both sum as well as the number.
10. Write a Java program using a method called char palindrome(int n) to print the number is Palindrome or Not.
[Date: 16/04/2026]
[Date of Submission: 20/04/2026]
Assignment on Method3
[Non-void Method without Parameters]
Write a Java program using the following given methods:
1. int sumOfNaturalNumbers( ) to print the sum of natural numbers(Limit user-given)
2. long factorial( ) to print the Factorial of User given number.
3. int sumOfFibonacci( ) to print the sum of Fibonacci Numbers of User given limit.
4. int sumOfDigits() to print the sum of the digits.
5. int greatestDigit() to print print the greatest digit.
6. int numberOfDigits() to print the number of the digits. Input: 852 Output: 3 Digits
7. int reverse( ) to print the reversed whole number. Input: 852 Output: 258.
8. boolean palindrome() to print the number is Palindrome or Not.
9. boolean neonNumber() to print the number is Neon Number or not.
10. boolean armstrongNumber() to print the number is Armstrong Number or not.
[Date: 31/03/2026]
[Date of Submission: 07/04/2026]
Sample Program of Method3:
import java.util.*;
class Method3
{
float square()
{
float n, sq;
Scanner sc=new Scanner(System.in);
System.out.print("Please Enter any Number to get Square:");
n=sc.nextFloat();
sq=n*n;
return sq;
}
public static void main()
{
float s;
Method3 ob=new Method3();
s=ob.square();
System.out.println("The Square of the Number is "+s);
}
}
Assignment on Method2
[void Method with Parameters]
1. Write a Java program using a method called void square(int n) to find the Square of any number.
2. Write a Java program using a method called void cube(int n) to find the Cube of any number.
3. Write a Java program using a method called void product(float a, float b) to find the Product of two numbers.
4. Write a Java program using a method called void division(float a, float b) to find the quotient of two numbers.
5. Write a Java program using a method called void areaOfRectangle(int l, int b) to find the Area of Rectangle.
6. Write a Java program using a method called void areaOfTriangle(float b, float h) to find Area of Triangle.
7. Write a Java program using a method called void areaOfCircle(float r) to find Area of Circle.
8. Write a Java program using a method called void simpleInterest(float p, float r, float t) to find the Simple Interest.
9. Write a Java program using a method called void areaOfRectangle(int l, int b), void perimeterOfRectangle(int l, int b) to find the area and perimeter of Rectangle.
10. Write a Java program using a method called void positiveNegative(int n), void oddOrEven(int n) to find the number is Positive/Negative and Even/Odd.
[Date: 17/03/2026]
[Date of Submission: 20/03/2026]
Sample Program of Method2:
import java.util.*;
class Method2
{
void square(float n)
{
float sq;
sq=n*n;
System.out.println("The Square of the Number is "+sq);
}
public static void main()
{
float n1;
Method2 ob=new Method2();
Scanner sc=new Scanner(System.in);
System.out.print("Please Enter any Number to get Square:");
n1=sc.nextFloat();
ob.square(n1); /**n1 is Method Argument*/
}
}
Assignment 1 on Method1
[void Method without Parameters]
1. Write a Java program using a method called void square() to find the Square of any number.
2. Write a Java program using a method called void cube() to find the Cube of any number.
3. Write a Java program using a method called void product() to find the Product of two number.
4. Write a Java program using a method called void division() to find the quotient of two number.
5. Write a Java program using a method called void square(), void cube() to find the square and cube of any number.
[Date: 12/03/2026]
[Date of Submission: 13/03/2026]
Sample Program of Method1:
import java.util.*;
class SquareOfNumber
{
void square()
{
float n, sq;
Scanner sc=new Scanner(System.in);
System.out.print("Please Enter any Number to get Square:");
n=sc.nextFloat();
sq=n*n;
System.out.println("The Square is "+sq);
}
public static void main()
{
SquareOfNumber ob=new SquareOfNumber();
ob.square(); /**Invoking Method or Calling Method*/
}
}