
views
Plan your program. Finding the sum of two numbers isn't difficult, but it is always a good practice to plan your program before beginning to code. Understand that you'd need two inputs/ parameters from the user for this program: the two numbers.
Write the code. Finding the sum of two numbers means the simple addition of both the numbers. Create a separate variable to store the value of the sum. This can be of the type int. The formula to find the sum is:Sum = First Number + Second Number To get these parameters (inputs) from the user, try using the Scanner function in Java.
Display the output. Once the program has calculated the sum, display it to the user. Use the System.out.print or System.out.println (to print on a new line) function, in Java, for this.
Comments
0 comment