12. Write a Java program to print the sum of two numbers.
import java.util.Scanner;
public class Q216735 {
/**
* Main method
*
* @param args
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the first number: ");
double firstNumber = input.nextDouble();
System.out.print("Enter the second number: ");
double secondNumber = input.nextDouble();
double sum = firstNumber + secondNumber;
System.out.println("Sum = " +sum);
input.close();
}
}
Comments
Leave a comment