Posts

Showing posts from September, 2017

Advance Java Application

/* Write a program in Java that takes two integer input from user then add them both and displays the output.*/ import java.util.Scanner; //program uses class scanner public class Calculator{           public static void main(String[ ] args)           {                int ,a,b,total;                 //create an Scanner object to read input from user.                 Scanner input =new Scanner(System.in);                              System.out.println("Enter first number:");                a=input.nextInt(); //read first number                 System.out.println("Enter second number:");                b=input.nextInt(); //read second number                             total=a+b;   //calculates the total                // prints the total result               System.out.println("Total sum is: "+total);            } } Output: Enter first number: 5 Enter second number: 5 Total sum is: 10 Above, the first statement which is writte