Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.2 kB
8
Indexable
Never
Author: Mehrab
Task1:

import java.util.Scanner;

public class Area {
   public static void main(String args[]){
      int radius;
      double area;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the radius of the circle ::");
      radius = sc.nextInt();
      area = (radius*radius)*Math.PI;
      System.out.println("Area of the circle is ::"+area);
   }
}

Task2:

import java.util.Scanner;

public class EvenOdd {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int num = sc.nextInt();

        if(num % 2 == 0)
            System.out.println(num + " is even");
        else
            System.out.println(num + " is odd");
    }
}


Task3:

import java.util.Scanner;

public class Factorial {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int i;
		int fact = 1;
		int number;
		System.out.println("Enter a number: ");
		Scanner sc = new Scanner(System.in);
		number = sc.nextInt();
		for(i=1; i<=number; i++)
		{
			fact = fact * i;
		}
		
		 System.out.println("Factorial of "+number+" is: "+fact);
	}

}


Task4:


Leave a Comment