Java Program: To find the largest among three numbers.

Hello Every One Today we are going to learn to write a program in Java. Which will find the largest among three integer numbers.

Welcome to this post by Techmoodly and Follow us for more information on Technology and Computer Programs.

Understand the Concept in Java:

So Here, We will take input from user for enter 3 numbers which can be anything. So We will have to make a program which will find the largest numbers from the inputted numbers by User.

If User will enter any 3 numbers like: 1, 5, 8 So Our Program should find the largest number here as 8. So I think You can not understand the concept.

So Lets have a look into Java Coding:

import java.util.Scanner;  
public class Exercise1_2 {
       public static void main(String[] args) {
        Scanner s = new Scanner(System.in); 
        int x = s.nextInt(); 
        int y = s.nextInt();
        int z = s.nextInt();
        int result = 0;

//Use if...else ladder to find the largest among 3 numbers and store the largest number in a variable called result.

  if(x>=y && x>=z)
    {
       System.out.print(x);
    }

    else if(y>=x && y>=z)
         {
             System.out.print(y);
         }
         else if(z>=x && z>=y)
              {
                 System.out.print(z);
              }

              else
                 {
                    System.out.print(result);
                 }
        }
}
input: 2,4,6 (x,y,z respectively)
output: 6 

So Hope you learnt something here. Guys If you know any other way to make this program output possible, So You are welcome here to Post or Comment. It may help others.

Thank you.

Write a Program to calculate the sum of n Even numbers Which is Divisible by 3 in Java.

Follow Us:

“Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday’s code.”

– Dan Salomon

TechMoodly is a YouTube channel and Tech Blog where We can Learn and Share All Knowledge and Experiences related To Tech blogs .

We are More Efficient for :

  • Hardware Tutorial
  • Networking Tutorial
  • Codes Tutorial
  • iOS Hacks
  • Software Tutorials
  • General Knowledges and
  • Other.

Loading