Answer to Question #216735 in Java | JSP | JSF for Zenifer

Question #216735

12. Write a Java program to print the sum of two numbers.


1
Expert's answer
2021-07-14T02:38:59-0400
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();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS