Input through Keyboard

/*The following program is written in a very simple form to show the keyboard input from the programmer which
returns the corresponding value conditioned by the if-statement in the method min(int, int) */

import java.io.*;

public class KeyBoardInput {

public static int min( int a, int b) {

            if (a <= b)
               return a;
            else
               return b;
}

public static void main(String[] args) throws IOException {

int x;
int y;

String sb;
String ks;
 

BufferedReader bk = new BufferedReader (
    new InputStreamReader(System.in));
 

System.out.println ("Enter x ");

     sb = bk.readLine();
     x = Integer.parseInt(sb);
 

System.out.println("Enter y");

     ks = bk.readLine();
     y = Integer.parseInt(ks);
 

 bk.close();
 

System.out.print("The returned value is =  ");
System.out.println(Math.min(x * 5, y + 20));
}
}

Thanks to Khaled Mahmud Shams for submitting the above Java program example.

Quick Links:
Have Java Problem
Do you have a Java Question?

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Best Regards,
Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.