Java Program to add two numbers from user Input
Addition.java
/* Code From Learnoset - Learn Code Online Android App.*/
/*Download Learnoset App from PlayStore to learn coding*/
/*Java Program to add two numbers from user Input*/
import java.util.Scanner;
class Addition {
public static void main(String[] args) {
/* Declare 3 int type variables a,b and c. a and b will hold 2 numbers on which we will perform addition & c will hold the result*/
int a, b, c;
Scanner scanner = new Scanner(System.in); // Create an object of scanner class to get input from user.
System.out.println("Enter First Number");
a = scanner.nextInt(); // Initialize 'a' variable with first number entered by user;
System.out.println("Enter Second Number");
b = scanner.nextInt(); // Initialize b variable with second number entered by user;
// Perform addition and save the result into c variable.
c = a + b;
// Now finally prints the result
System.out.println("Addition of " + a + " and " + b + " is = " + c);
}
}
/*----------OUTPUT----------
Enter First Number
5
Enter Second Number
6
Addition of 5 and 6 is = 11
*/
Projects with Source Code + Video Tutorials
You can download our Java and Android Studio Projects with Source Code and Video Tutorials.
![Bottom-Navigation-Bar-with-Fragments-+-Animation](https://learnoset.com/Learnoset/Projects/BottomNavigationBar/thumbnail.jpg)
Bottom Navigation Bar with Fragments + Animation
![Login-and-Register-Activity-Material-UI-design-in-Android-Studio](https://learnoset.com/Learnoset/Projects/LoginAndRegister05/login_register_05.png)
Login and Register Activity Material UI design in Android Studio
![Settings-and-Profile-page-UI-design-in-Android-Studio-with-Example-and-Source-Code](https://learnoset.com/Learnoset/Projects/SettingsPageUI/settings-profile-page-material-ui-design-in-android-studio.png)
Settings and Profile page UI design in Android Studio with Example and Source Code
If you have any Questions or Queries
You can mail us at info.learnoset@gmail.com
Follow us to learn Coding and get in touch with new Technologies.