Largest Number – Java Program

Here is a simple Java program that takes 3 inputs in integer from the user and prints the largest number.

Screen Shot 2018-04-12 at 9.52.09 PM

import java.util.Scanner;

public class biggestnumber {
public static void main(String args[])
{
int d = 0;
int v = 0;
Scanner firstnumber = new Scanner(System.in);
System.out.println(“Enter first number: “);
int a = firstnumber.nextInt();

Scanner secondnumber = new Scanner(System.in);
System.out.println(“Enter second number: “);
int b = secondnumber.nextInt();

Scanner reader = new Scanner(System.in);
System.out.println(“Enter third number: “);
int c = reader.nextInt();

if (a>b)
d = a;
else
d = b;

if (d>c)
v = d;
else
v = c;

System.out.println(+v);
}
}

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s