Skip to content

Commit 92b0a05

Browse files
committed
feat: Add Sum class to calculate the sum of two floating-point numbers
Add a program that: - Prompts the user to input two float values - Computes and prints their sum - Demonstrates use of `Scanner` for input and basic arithmetic with float types in Java.
1 parent 270c1f7 commit 92b0a05

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Section5OperatorExpression/src/Sum.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
public class Sum {
44
public static void main(String[] args) {
55
Scanner input = new Scanner(System.in);
6+
System.out.println("Enter a two numbers: ");
7+
68
float num1 = input.nextFloat();
79
float num2 = input.nextFloat();
8-
910
float sum = num1 + num2;
1011

1112
System.out.println("Sum = " + sum);

0 commit comments

Comments
 (0)