- 1

Write a program to add 2 numbers A) initialised by yourself B) take user input using scanner class

Java

26th Nov 2021, 1:55 PM
Kritika Kohli
2 Réponses
+ 4
Have you started learning java if not then read about the data types and input statement about scanner class. Simply declare two variables depends on the data type for example for integer u can write like this int a,b; Then u need to ask for user input so for this u need to import scanner class then Write like this Scanner sc= new Scanner (System.in); a=sc.nextInt() ; // this is for input one Same do for other number and use print statement to print the output
26th Nov 2021, 6:47 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Hello Kritika Kohli Please show us your attempt.
26th Nov 2021, 2:44 PM
Denise Roßberg
Denise Roßberg - avatar