Add Function
1 import java.util.Scanner;
2
3
4 public class Add {
5
6 public static void main (String [] args) {
7
8 String word1;
9 Scanner scan = new Scanner(System.in);
10
11 System.out.println("What is the unit of measurement?");
12
13 word1 = scan.nextLine();
14
15 System.out.println("Input first number plz");
16
17 int num1 = scan.nextInt();
18
19 System.out.println("Input second number plz");
20
21 int num2 = scan.nextInt();
22
23 int num3 = num1 + num2;
24
25 System.out.println("The answer is: " + num3 + " " + word1);
26 }
27 }
Comments
Sign in to leave a comment.

