Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > Java Forum & Tutorial


Input through Keyboard


Reply
Views: 2067  
Thread Tools Rate Thread
  #1  
Old 05-24-2009, 03:16 PM
bholus7
Guest
 
Posts: n/a
Default Input through Keyboard

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));
}
}

Reply With Quote
Reply

New topics in Java Forum & Tutorial





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)