We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 687698e commit bd03b99Copy full SHA for bd03b99
1 file changed
AddRealNumbers.java
@@ -0,0 +1,18 @@
1
+import java.util.Scanner; // Import the Scanner class
2
+
3
+class AddRealNumbers {
4
+ public static void main(String[] args) {
5
+ double x, y, sum;
6
+ Scanner scans = new Scanner(System.in); // Create a Scanner object
7
+ System.out.println("Type a number:");
8
+ x = scans.nextDouble(); // Read user input
9
10
+ System.out.println("Type another number:");
11
+ y = scans.nextDouble(); // Read user input
12
13
+ scans.close();
14
15
+ sum = x + y; // Calculate the sum of x + y
16
+ System.out.println("Sum is: " + sum); // Print the sum
17
+ }
18
+}
0 commit comments