Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MiddleNumber{
  4.     public static int annaKeskimmäinen(int first, int second, int third){
  5.         if (first <= second && first >= third || first >= second && first <= third){
  6.             System.out.println("The number in middle is " + first + ".");
  7.         }
  8.         if (second < first && second > third || second > first && second < third){
  9.             System.out.println("The number in middle is " + second + ".");
  10.         }
  11.         if (third < first && third > second || third > first && third < second){
  12.             System.out.println("The number in middle is " + third + ".");
  13.         }
  14.     }
  15.     public static void main(String[] args){
  16.         Scanner reader = new Scanner(System.in);
  17.         System.out.println("Hello! I determine the number in the middle.");
  18.         System.out.println("Please, enter the first number:");
  19.         int num1 = reader.nextInt();
  20.         System.out.println("Please, enter the second number:");
  21.         int num2 = reader.nextInt();
  22.         System.out.println("Please, enter the third number:");
  23.         int num3 = reader.nextInt();
  24.         annaKeskimmäinen(num1, num2, num3);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement