Java code practice 01Java Program to Print an Integer (Entered by the User) In this program, you'll learn to print a number entered by the user in Java. The integer is stored in a variable using System.in, and is displayed on the screen using System.out.
Java code practice 02
Method 1: Sum of two numbers This is the most easiest way to find the sum of two numbers in Java. We will initialize and declare the value in the program itself. Here the input is not taken from the user.
Java code practice 03
Method 2: Add Two Numbers in Java With User Input In Java, the Scanner class is one of the classes which fetches the user input. Example
Java code practice 04
Java Program to Multiply two Floating Point Numbers In this program, you'll learn to multiply two floating point numbers in Java, store the result and display it on the screen.
Java code practice 05
Java Program to Swap Two Numbers In this program, you'll learn two techniques to swap two numbers in Java. The first one uses a temporary variable for swapping, while the second one doesn't use any temporary variables.
Java code practice 06
Java Program to Check Whether a Number is Even or Odd In this program, you'll learn to check if a number entered by an user is even or odd. This will be done using if...else statement and ternary operator in Java.
Java code practice 07
Java Program to Find the Largest Among Three Numbers In this program, you'll learn to find the largest among three numbers using if else and nested if..else statement in Java.
Java code practice 08
Java Program to Find largest of Two Numbers using Else If This Java program allows the user to enter two different values. Next, this Java program finds the largest number among those two numbers using Else If Statement
Java code practice 09
Java Program for Largest of Three Numbers using Else If Statement This Java program helps the user to enter three different values and finds the largest number among that three numbers using the Else If Statement
Java code practice 10Java Program to Concatenate Two Strings This is a Java Program to Perform String Concatenation.
Enter any two strings as input. We have made a function into which we pass the two given strings and this function uses concatenation operator for string concatenation and hence return the desired string back to the main function. Here is the source code of the Java Program to Perform String Concatenation. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
Java code practice 11
Java Program to Find the Area of a Circle This is a Java Program to Find the Area of a Circle Given the Radius.
Area = pi * r * r
Enter the radius of the circle as an input. Now we use the given formula to calculate the area of the circle.
Java code practice 12
Java Program to Find the Perimeter of a Circle, Rectangle and Triangle This is a Java Program to Find the Perimeter of a Circle, Rectangle and Triangle.
formula:
Perimeter of circle=2*pi*r
Perimeter of rectangle=2*(l+b)
Perimeter of triangle=(s1+s2+s3)
Enter the radius of the circle, length and breadth of the rectangle and three sides of the triangle as inputs. Calculate the perimeter by using formula and get the desired output.
0 Comments