Java program to find maximum of three numbers

karthikeya Boyini
Updated on 14-Jun-2024 15:42:43

22K+ Views

The maximum among three numbers can be found using an if else statement. A Java program that demonstrates this is given as follows.Example Live Demopublic class Example {    public static void main(String args[]) {       int num1 = 15;       int num2 = -5;       int num3 = 7;       if (num1 >= num2 && num1 >= num3)          System.out.println( num1 + " is the maximum number.");       else if (num2 >= num1 && num2 >= num3)          System.out.println( num2 + " is the ... Read More

Java Program to Reverse a List

Rudradev Das
Updated on 14-Jun-2024 15:35:05

17K+ Views

What is a Reverse List? Reverse a list is an operation of swapping or interchanging the elements position into a particular list. While you are writing a code in Java, you can easily reverse the order of a certain flow. It is a conventional way of any programming language in computer science. The reverse () method is a collection of class which reverses the position of first element to last element. Last element will earn the first position itself after the termination of the process. A list is an interface where the class method is denoted as a signature with ... Read More

JavaScript program to find area of a circle

AmitDiwan
Updated on 14-Jun-2024 14:53:59

14K+ Views

We will be using the below formula to find the area of a circle − pi * r^2 In the program, we will prompt the user to input the radius of the circle. Then, we will use the formula to calculate the area and print it on the screen. Approach Get the radius of the circle from the user as an input. Calculate the area using the formula: area = π * radius^2 Store the value of π, it can be calculated using Math.PI in JavaScript. Multiply the value of π with the square of ... Read More

Java Program to pass method call as arguments to another method

AmitDiwan
Updated on 14-Jun-2024 14:49:44

20K+ Views

In this article, we will understand how to pass method call as arguments to another method. We can call a method from another class by just creating an object of that class inside another class. After creating an object, call methods using the object reference variable.Below is a demonstration of the same −InputSuppose our input is −Enter two numbers : 2 and 3OutputThe desired output would be −The cube of the sum of two numbers is: 125AlgorithmStep 1 - START Step 2 - Declare two variables values namely my_input_1 and my_input_2 Step 3 - We define a function that takes ... Read More

Java Program to access character of a string

karthikeya Boyini
Updated on 14-Jun-2024 14:44:43

31K+ Views

To access character of a string in Java, use the charAt() method. The position is to be added as the parameter.Let’s say we have the following string −String str = "laptop";Let’s find the character at the 4th position using charAt() method.str.charAt(3));The following is the final example.Example Live Demopublic class Demo {    public static void main(String[] args) {       String str = "laptop";       System.out.println("String: "+str);       // finding character at 4th position       System.out.println("Character at 4th position: "+str.charAt(3));    } }OutputString: laptop Character at 4th position: t

Java program to find the sum of elements of an array

Lakshmi Srinivas
Updated on 14-Jun-2024 14:12:56

44K+ Views

To find the sum of elements of an array.create an empty variable. (sum)Initialize it with 0 in a loop.Traverse through each element (or get each element from the user) add each element to sum.Print sum.Exampleimport java.util.Arrays; import java.util.Scanner; public class SumOfElementsOfAnArray {    public static void main(String args[]){       System.out.println("Enter the required size of the array :: ");       Scanner s = new Scanner(System.in);       int size = s.nextInt();       int myArray[] = new int [size];       int sum = 0;       System.out.println("Enter the elements of the array one by one ");       for(int i=0; i

Java program to calculate the percentage

Lakshmi Srinivas
Updated on 14-Jun-2024 13:37:08

28K+ Views

Percent means percent (hundreds), i.e., a ratio of the parts out of 100. The symbol of a percent is %. We generally count the percentage of marks obtained, return on investment etc. The percentage can go beyond 100% also.For Example, assuming that we have total and a part. So we say what part is what percent of total and should be calculated as −percentage = ( part / total ) × 100AlgorithmBelow is the algorithm to calculate percentage in Java:1. Collect values for part and total 2. Apply formula { percentage = ( part / total ) × 100 } ... Read More

Java program to find the GCD or HCF of two numbers

Chandu yadav
Updated on 14-Jun-2024 13:21:32

28K+ Views

An H.C.F or Highest Common Factor, is the largest common factor of two or more values.For example factors of 12 and 16 are −12 → 1, 2, 3, 4, 6, 12 16 → 1, 2, 4, 8, 16The common factors are 1, 2, 4 and the highest common factor is 4.AlgorithmDefine two variables - A, BSet loop from 1 to max of A, BCheck if both are completely divided by same loop number, if yes, store itDisplay the stored number is HCFExample: Using Java for loop import java.util.Scanner; public class GCDOfTwoNumbers {    public static void main(String args[]){   ... Read More

rtop - An Interactive Tool to Monitor Remote Linux Server Over SSH

Ayush Singh
Updated on 13-Jun-2024 14:36:52

476 Views

Rtop is a live monitoring tool for remote Linux servers connected over SSH. Users can use Rtop to actively monitor crucial server metrics including CPU, memory, network, and disc utilisation. The application gives admins a real-time overview of system performance and enables them to spot possible problems or bottlenecks. Users can browse through various metrics, organise them, and view precise process-specific information using the interactive interface of Rtop. It provides a practical and effective solution to monitor remote servers closely, making it simpler to identify and rapidly address any performance-related issues. Methods Used Command-Line Monitoring Tools Web-Based Monitoring Tools ... Read More

OTI and WTI in Transformer

Manish Kumar Saini
Updated on 10-Jun-2024 16:57:17

156 Views

OTI (Oil Temperature Indicator) and WTI (Winding Temperature Indicator) are two important components of an electrical transformer. OTI and WTI are the essential components of an electrical transformer, as they ensure the safe and reliable operation of the transformer. The primary function of both these indicators is the same i.e., monitoring and displaying the temperature. OTI (Oil Temperature Indicator) monitors and shows the temperature of transformer oil filled in the tank, while WTI (Winding Temperature Indicator) shows the temperature of windings of the transformer. Read this article to learn more about these two types of temperature indicators. What is an ... Read More

Advertisements