Java Program to find Biggest of Three Numbers

You are Here:

Find Biggest of Three Numbers

In the following example, we will find which of the following numbers (40, 25, 7) is the biggest number.

Example

Java Compiler
public class myClass { public static void main(String[] args) { int a = 40; int b = 25; int c = 7; System.out.format("The numbers are a = %d, b = %d, c = %d",a, b, c); if((a > b) && (a > c)) System.out.format("\na = %d is the biggest number", a); else if(b > c) System.out.format("\nb = %d is the biggest number", b); else System.out.format("\nc = %d is the biggest number", c); } }

Output

The numbers are a = 40, b = 25, c = 7 a = 40 is the biggest number

Find Biggest of any Given Three Numbers

In the following example, we will find the biggest of any given three numbers.

Example

Java Compiler
import java.util.Scanner; public class myClass { public static void main(String[] args) { Scanner reader = new Scanner(System.in); int a, b, c; System.out.print("Enter an integer for a = "); a = reader.nextInt(); System.out.print("Enter an integer for b = "); b = reader.nextInt(); System.out.print("Enter an integer for c = "); c = reader.nextInt(); if((a > b) && (a > c)) System.out.format("\na = %d is the biggest number", a); else if(b > c) System.out.format("\nb = %d is the biggest number", b); else System.out.format("\nc = %d is the biggest number", c); } }

Output

Enter an integer for a = 5 Enter an integer for b = 4 Enter an integer for c = 8 c = 8 is the biggest number

Reminder

Hi Developers, we almost covered 90% of String functions and Interview Question on Java with examples for quick and easy learning.

We are working to cover every Single Concept in Java.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author