Click here to watch in Youtube :
https://www.youtube.com/watch?v=rCsBg9VujdM&list=UUhwKlOVR041tngjerWxVccw
ScannerDemo.java
Output
https://www.youtube.com/watch?v=rCsBg9VujdM&list=UUhwKlOVR041tngjerWxVccw
ScannerDemo.java
import java.util.Scanner; public class ScannerDemo { public static void main(String[] args) { Scanner scanner = null; try { scanner = new Scanner(System.in); System.out.print("Enter the first number: "); int number1 = scanner.nextInt(); System.out.print("Enter the second number: "); int number2 = scanner.nextInt(); int sum = number1 + number2; System.out.println("sum = " + sum); } finally { if (scanner != null) { scanner.close(); } } } }
Enter the first number: 10 Enter the second number: 20 sum = 30
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_Scanner_sum_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_Scanner_sum_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/16638d65b46bec1088dab744ba69a31424c4a14f/BasicJava/JavaIODemo_Scanner_sum_App/?at=master
See also:
No comments:
Post a Comment