Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MiddleNumber{
- public static int annaKeskimmäinen(int first, int second, int third){
- if (first <= second && first >= third || first >= second && first <= third){
- System.out.println("The number in middle is " + first + ".");
- }
- if (second < first && second > third || second > first && second < third){
- System.out.println("The number in middle is " + second + ".");
- }
- if (third < first && third > second || third > first && third < second){
- System.out.println("The number in middle is " + third + ".");
- }
- }
- public static void main(String[] args){
- Scanner reader = new Scanner(System.in);
- System.out.println("Hello! I determine the number in the middle.");
- System.out.println("Please, enter the first number:");
- int num1 = reader.nextInt();
- System.out.println("Please, enter the second number:");
- int num2 = reader.nextInt();
- System.out.println("Please, enter the third number:");
- int num3 = reader.nextInt();
- annaKeskimmäinen(num1, num2, num3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement