Learning To Code In Java: Program To Add Two Numbers
This blog post will provide you with the source code of a program written in Java to add two numbers. So let's get started. Source Code: import java.util.Scanner;public class AddTwoNumsApp1 { public static void main(String[] args) { Scanner Sum2Nums = new Scanner(System.in); System.out.println("nEnter the first number: "); int FirstNum = Sum2Nums.nextInt(); System.out.println("nEnter the second number: "); int SecondNum = Sum2Nums.nextInt(); int Total = FirstNum + SecondNum; System.out.println("nThe total of 2 numbers are: "+ Total + ".n"); Sum2Nums.close(); }} Output: That's it, a Java program to add two numbers has successfully been created.