Tag

#java number programs

21 posts

Perfect Square Program in Java

In this tutorial, we will write a java program to check if a given number is a perfect square or not. Before that, you should have knowledge of the following topic in Java. java function if..elsestatement in java We will look at two java perfect square programs: With sqrt() function Without sqrt() f

October 6, 2021Read more →

Java Program to Find the LCM of Two Numbers

Here, we will write a program to calculate the LCM of two numbers in java. LCM stands for Lowest Common Factor. The Numbers will be taken as input from the user using the scanner class. Before we start, click on the links below to have a proper working idea of the if statement and break … Read

March 19, 2021Read more →

Java Program to Find the Greatest of Three Numbers

The following program takes three integers from the user and finds the largest of those three numbers. The program uses if..elseif statement to check the greatest of three and print them accordingly. Before we start, click on the links below to have a proper working idea of if..elseif statement that

March 19, 2021Read more →

Java Program to Display the Odd Numbers

The following program takes the value for n that is the max limit of n from the user. The program starts checking for odd numbers between this range 1 to n and it displays all the odd numbers lying within that range. Before we start, click on the links below to have a proper working … Read mor

March 19, 2021Read more →

Java Program to Check Positive or Negative Numbers

In this tutorial, we will write a program to check whether the number is positive or negative in java. The program takes the user input for the number to be checked and performs the calculation. Before, we begin you need to have the idea of the proper working of if-else..if statement. Click the link

March 19, 2021Read more →

Java Program to Find a Factorial of a Number

In this example, we will calculate the factorial of a number taking the value from the user. You may also learn to find Factorial of a Number in Java Using recursion. Before we begin, you should have the knowledge of the following: Java Data-Types Java Operators Java for loop Factorial of n number:

March 17, 2021Read more →

Java Program to Find the Sum of Natural Numbers

It is the Basic Java Program to find the sum of N natural numbers. The program below uses the While loop, if you want to learn about the while loop click below. While loop in Java Example: If you want to find the sum of 5 natural numbers, the process will be executed in this … Read more

March 16, 2021Read more →

Java Program to Generate Random Numbers

Generating Random numbers in java is quite easy as it provides various classes to do that. It comes in handy when needed to apply to any kind of application development that might require random number generation. Let start by knowing random numbers. What is Randon Number? We can define Random as so

March 15, 2021Read more →