Skip to content

Commit bd03b99

Browse files
Create AddRealNumbers.java
1 parent 687698e commit bd03b99

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

AddRealNumbers.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)