-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestScanner.java
More file actions
31 lines (23 loc) · 837 Bytes
/
TestScanner.java
File metadata and controls
31 lines (23 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package testscanner;
import java.util.Scanner;
public class TestScanner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// System.out.println("Give me a Input....");
// String name = scanner.nextLine();
// System.out.println("Name: " + name);
System.out.println("\"ADDing two numbers...\"");
System.out.println("Give me a 1st Number..");
float firstNum = scanner.nextFloat();
System.out.println("First Number = " + firstNum);
System.out.println("Give me a 2nd Number..");
float secondNum = scanner.nextFloat();
System.out.println("Second Number = " + secondNum);
float result = add(firstNum, secondNum);
System.out.println("Result: " + result);
}
public static float add(float firstNum, float secondNum) {
float result = firstNum + secondNum;
return result;
}
}