Last active
April 14, 2016 01:40
-
-
Save itsJarrett/07a76fbee2bb9ffcb34e to your computer and use it in GitHub Desktop.
Find out if two numbers have a middle!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
middleNumber(); | |
} | |
public static void middleNumber() { | |
Scanner s = new Scanner(System.in); | |
System.out.println("Enter the first number."); | |
double one = s.nextDouble(); | |
System.out.println("Enter the second number."); | |
double two = s.nextDouble(); | |
double number = one + two; | |
number = number / 2; | |
if (number % 1 == 0) { | |
System.out.println("Congratulations, those numbers have a middle! The middle number is " + number + "!"); | |
} else { | |
System.out.println("Those two numbers have no middle :( !"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment