Java Keyboard entry

Source: Internet
Author: User

Scanner Keyboard entry

Import Java.util.scanner;public class Scannerdemo {public static void main (string[] args) {Scanner sc = new Scanner (System . in); System.out.println ("Please enter a data integer"); int x = Sc.nextint (); System.out.println ("Please enter a second data integer"); int y = Sc.nextint (); System.out.println ("x + y =" + (x + y));}}
Import java.util.scanner;class scannertest2{public static void main (String[]  args)  {//Create object Scanner sc = new scanner (system.in); System.out.println ("Enter the first number (an integer)!"); Int x = sc.nextint (); System.out.println ("Enter the second number (an integer)!"); Int y = sc.nextint ();         system.out.println (" Enter a third number (integer)! "); Int z = sc.nextint ();        //system.out.println ("is the first two numbers equal?") + (x==y));        //first determine x, y larger value     //int max1 =   (x>y ? x : y)        //larger value with Z judgment     // int max =  (max1>z ? max1 : z);    //Improved version method     nested Use        int max =  x >  y ?  (x>z ? x:z)  : (y>z?y:z);  system.out.println ("Maximum of three numbers is:!") +max);}}


This article from the "Clear Sky" blog, declined reprint!

Java Keyboard entry

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.