Found 7442 Articles for Java

Java program to find the area of a circle

karthikeya Boyini
Updated on 13-Mar-2020 09:43:27

22K+ Views

Area of a circle is the product of the square of its radius, and the value of PI, Therefore, to calculate the area of a rectangleGet the radius of the circle.Calculate the square of the radius.Calculate the product of the value of PI and the value of the square of the radius.Print the result.Exampleimport java.util.Scanner; public class AreaOfCircle {    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();   ... Read More

Java program to find the area of a circle

karthikeya Boyini
Updated on 13-Mar-2020 09:43:27

22K+ Views

Area of a circle is the product of the square of its radius, and the value of PI, Therefore, to calculate the area of a rectangleGet the radius of the circle.Calculate the square of the radius.Calculate the product of the value of PI and the value of the square of the radius.Print the result.Exampleimport java.util.Scanner; public class AreaOfCircle {    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();   ... Read More

Java program to find the area of a triangle

George John
Updated on 13-Mar-2020 08:19:28

4K+ Views

Area of a triangle is half the product of its base and height. Therefore, to calculate the area of a triangle.Get the height of the triangle form the user.Get the base of the triangle form the user. Calculate their product and divide the result with 2.Print the final result.Exampleimport java.util.Scanner; public class AreaOfTriangle {    public static void main(String args[]){       int height, base, area;       Scanner sc = new Scanner(System.in);       System.out.println("Enter the height of the triangle ::");       height = sc.nextInt();       System.out.println("Enter the base of the triangle ::"); ... Read More

Java program to find the area of a triangle

George John
Updated on 13-Mar-2020 08:19:28

4K+ Views

Area of a triangle is half the product of its base and height. Therefore, to calculate the area of a triangle.Get the height of the triangle form the user.Get the base of the triangle form the user. Calculate their product and divide the result with 2.Print the final result.Exampleimport java.util.Scanner; public class AreaOfTriangle {    public static void main(String args[]){       int height, base, area;       Scanner sc = new Scanner(System.in);       System.out.println("Enter the height of the triangle ::");       height = sc.nextInt();       System.out.println("Enter the base of the triangle ::"); ... Read More

Java program to find the area of a rectangle

Samual Sam
Updated on 18-Jun-2024 16:59:45

15K+ Views

Area of a rectangle is the product of its length and breadth. Therefore, to calculate the area of a rectangleGet the length of the rectangle form the user.Get the breadth of the rectangle form the user.Calculate their product.Print the product.ExampleBelow is an example to find the area of a rectangle in Java using Scanner class.import java.util.Scanner; public class AreaOfRectangle {    public static void main(String args[]){       int length, breadth, area;       Scanner sc = new Scanner(System.in);       System.out.println("Enter the length of the rectangle ::");       length = sc.nextInt();       ... Read More

Java program to find the area of a rectangle

Samual Sam
Updated on 18-Jun-2024 16:59:45

15K+ Views

Area of a rectangle is the product of its length and breadth. Therefore, to calculate the area of a rectangleGet the length of the rectangle form the user.Get the breadth of the rectangle form the user.Calculate their product.Print the product.ExampleBelow is an example to find the area of a rectangle in Java using Scanner class.import java.util.Scanner; public class AreaOfRectangle {    public static void main(String args[]){       int length, breadth, area;       Scanner sc = new Scanner(System.in);       System.out.println("Enter the length of the rectangle ::");       length = sc.nextInt();       ... Read More

Java program to find the area of a square

Shriansh Kumar
Updated on 11-Sep-2024 11:05:11

9K+ Views

Given a square whose length of all its sides are l, write a Java program to find its area. A square is a rectangle whose length and breadth are same. Therefore, area of this type of rectangle is the square of its length. To calculate the area of square in Java, you simply need to multiply the given length of square with the length itself and store the result in another variable. Java Program to Find The Area of a Square A Java program that illustrates how to find the area of the square is shown below − public class ... Read More

Java program to find the area of a square

Shriansh Kumar
Updated on 11-Sep-2024 11:05:11

9K+ Views

Given a square whose length of all its sides are l, write a Java program to find its area. A square is a rectangle whose length and breadth are same. Therefore, area of this type of rectangle is the square of its length. To calculate the area of square in Java, you simply need to multiply the given length of square with the length itself and store the result in another variable. Java Program to Find The Area of a Square A Java program that illustrates how to find the area of the square is shown below − public class ... Read More

Write an example to find whether a given string is palindrome using recursion

Arjun Thakur
Updated on 13-Mar-2020 07:31:14

1K+ Views

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.Following is an example to find palindrome of a given number using recursive function.Examplepublic class PalindromeRecursion {    public static boolean isPalindrome(String str){       if(str.length() == 0 ||str.length()==1){          return true;       }       if(str.charAt(0) == str.charAt(str.length()-1)){          return isPalindrome(str.substring(1, str.length()-1));       }       return false; ... Read More

Write an example to find whether a given string is palindrome using recursion

Arjun Thakur
Updated on 13-Mar-2020 07:31:14

1K+ Views

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.Following is an example to find palindrome of a given number using recursive function.Examplepublic class PalindromeRecursion {    public static boolean isPalindrome(String str){       if(str.length() == 0 ||str.length()==1){          return true;       }       if(str.charAt(0) == str.charAt(str.length()-1)){          return isPalindrome(str.substring(1, str.length()-1));       }       return false; ... Read More

Advertisements