Skip to content

Commit

Permalink
Add Sum of Two given Numbers in Java
Browse files Browse the repository at this point in the history
I made an implementation that calculates the Sum of Two given Numbers in Java
  • Loading branch information
AhmadAnzar authored and x0lg0n committed Oct 26, 2024
1 parent ec8e11f commit 12af650
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Java/SumOfTwoNumbers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;

public class SumOfTwoNumbers {
public static void main(String[] args) {
// Create a Scanner object to read input from the user
Scanner sc = new Scanner(System.in);

// Prompt the user to enter the first number
System.out.print("Enter first number: ");
int a = sc.nextInt(); // Read the first integer input

// Prompt the user to enter the second number
System.out.print("Enter second number: ");
int b = sc.nextInt(); // Read the second integer input

// Calculate the sum of the two numbers
int sum = a + b;

// Print the result to the console
System.out.println("The sum is: " + sum);

// Close the Scanner
sc.close();
}
}

0 comments on commit 12af650

Please sign in to comment.