476179

reading key

Oct 8th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. package lessons;
  2.  
  3. import java.util.Scanner;
  4. //imports scanner class from java library
  5.  
  6. //write program that asks use for 3 integers an displays on screen
  7.  
  8. public class ReadingKeyboardInput
  9. {
  10.  
  11. public static void main(String[] args)
  12. {
  13. Scanner keyboard = new Scanner(System.in);
  14. //creates ref var called keyboard and creates new scanner thats connected to ref variable
  15.  
  16. int num1, num2, num3;
  17. System.out.print("enter three intiger values seperated by a space;");
  18. num1 = keyboard.nextInt();
  19. num2 = keyboard.nextInt();
  20. num3 = keyboard.nextInt();
  21.  
  22. System.out.println("you enetred "+ num1);
  23. System.out.println("you enetred "+ num2);
  24. System.out.println("you enetred "+ num3);
  25.  
  26. keyboard.close();
  27.  
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment