-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComparingNumbers.java
36 lines (28 loc) · 1.16 KB
/
ComparingNumbers.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
public class ComparingNumbers {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
double first, second;
System.out.print( "Give me two numbers. First: " );
first = keyboard.nextDouble();
System.out.print( "Second: " );
second = keyboard.nextDouble();
if ( first < second )
System.out.println( first + " is LESS THAN " + second );
if ( first <= second )
System.out.println( first + " is LESS THAN/EQUAL TO " + second );
if ( first == second )
System.out.println( first + " is EQUAL TO " + second );
if ( first >= second )
System.out.println( first + " is GREATER THAN/EQUAL TO " + second );
if ( first > second )
System.out.println( first + " is GREATER THAN " + second );
if ( first != second ) {
System.out.println( first + " is NOT EQUAL TO " + second );
System.out.println( "Hey." );
}
/* 1. The Hey. statement appears even when our two numbers are equal,
such as 4 == 4. I believe this is because curly braces have not been added
to contain both statements into the if ( first != second ) body.*/
}
}