Java Program to find Biggest of Three Numbers

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); } }

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); } }

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