Java List Odd Numbers

  Program to List Odd Numbers in Java. /** * Program to List Odd Numbers Java Example. * @author W3schools360 */ public class ListOddNumberExample { static void listOddNumber(int limitNumber){ //Print limit number. System.out.println(“Odd numbers between 1 and ” + limitNumber + “:”); //Find odd numbers. for(int i=1; i <= limitNumber; i++){ //Test odd number condition. … Read more

Java List Even Numbers

  Program to List Even Numbers in Java. /** * Program to List Even Numbers Java Example. * @author W3schools360 */ public class ListEvenNumberExample { static void listEvenNumber(int limitNumber){ //Print limit number. System.out.println(“Even numbers between 1 and ” + limitNumber + “:”); //Find even numbers. for(int i=1; i <= limitNumber; i++){ //Test even number condition. … Read more

Java Calculate Rectangle Perimeter

Perimeter of a rectangle = 2 * (length + width). Program to Calculate Rectangle Perimeter using Java. /** * Program to Calculate Rectangle Perimeter using Java Example. * @author W3schools360 */ public class RectanglePerimeterExample { static void rectanglePerimeter(int length, int width) { int perimeter = 2 * (length + width); //Print Rectangle Area. System.out.println(“Rectangle Perimeter: … Read more

Calculate Rectangle Area using Java Example

  Area of a rectangle = length * width. Program to Calculate Rectangle Area using Java. /** * Program to Calculate Rectangle Area using Java Example. * @author W3schools360 */ public class RectangleAreaExample { static void rectangleArea(int length, int width){ //Calculate Rectangle Area. int area = length * width; //Print Rectangle Area. System.out.println(“Rectangle area: ” … Read more

Java Calculate Circle Perimeter

Perimeter of a circle = 2 * pi * r. where: r is the radius of the circle. pi is a mathematical constant. Program to Calculate Circle Perimeter using Java. /** * Program to Calculate Circle Perimeter using Java Example. * @author W3schools360 */ public class CirlePerimeterExample { static void circlePerimeter(int radius){ //Calculate Circle Perimeter. … Read more

Java Reverse Number

  Program to Reverse the digits of a Number. /** * This program is used to reverse the digits of a number. * @author W3schools360 */ public class ReverseNumberExample { static void reverseNum(int num){ //Print reverse number. System.out.println(“Numer before reverse process: ” + num); int newNum = 0, reminder, temp; temp = num; //Reverse the … Read more

Java Swap Numbers

  Program to swap two numbers using third or temp variable. /** * This program is used to swap to numbers using temp variable. * @author W3schools360 */ public class SwapNumberExample { static void swapNumbers(int num1, int num2){ int temp = num1; num1 = num2; num2 = temp; System.out.println(“After swapping: “+ num1 + ” and … Read more