Java program that reads in three floating­ point numbers and prints the largest of the three inputs
###### Posted by Samath
Last Updated: February 12, 2021

Write a program that reads in three floating­point numbers and prints the largest of the three inputs without using the max function. For example:
Enter a number: 4
Enter a number: 9
Enter a number: 2.5
The largest number is 9.0

Code:

```import java.util.Scanner;

public class Main
{
public static void main(String[] args) {
double num1;
double num2;
double num3;
double largest;

Scanner input = new Scanner(System.in);

System.out.println("Enter first number: ");
num1 = input.nextDouble();

System.out.println("Enter second number: ");
num2 = input.nextDouble();

System.out.println("Enter third number: ");
num3 = input.nextDouble();
input.close();

if (num1 >= num2 && num1 > num3) {
largest = num1;
} else if (num2 > num1 && num2 >= num3){
largest = num2;
} else {
largest = num3;
}
System.out.println("Largest number: " + largest);
}
}
```
###### Java program that read a sequence of integer inputs and print the smallest and largest of the inputs
Samath | Apr 03, 2022
###### Java program that reads in two floating-point numbers and tests whether they are the same
Samath | May 08, 2021
###### Java program that read a sequence of integer inputs and print the number of even and odd inputs.
Samath | Apr 03, 2022
###### Java program that reads a floating ­point number and prints zero if the number is zero. Otherwise, print positive or negative
Samath | Feb 11, 2021
###### C++ program that find the largest number and counts its occurrences
Samath | Jan 20, 2024
###### C Program to Find Largest Element in Array
Samath | Jan 02, 2017
###### Java program that uses a loop to compute the sum of all even numbers between a and b (inclusive), where a and b are inputs
Samath | Apr 03, 2022