forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.java
More file actions
33 lines (26 loc) · 843 Bytes
/
Demo.java
File metadata and controls
33 lines (26 loc) · 843 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
32
33
import java.util.Scanner;
public class Demo
{
public static void main(String[] args)
{
printGreeting("HELLO");
Scanner input = new Scanner(System.in);
System.out.println("Enter a number: ");
int firstNumber = input.nextInt();
System.out.println("Enter a number: ");
int secondNumber = input.nextInt();
//int total = firstNumber + secondNumber;
//System.out.println("The total is " + total);
int myTotal = getTotal(firstNumber, secondNumber);
System.out.println("The total is: " + myTotal);
}
public static int getTotal(int number1, int number2)
{
int total = number1 + number2;
return total;
}
public static void printGreeting(String greeting)
{
System.out.println("<<<" + greeting + ">>>");
}
}