-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelloWorld.java
More file actions
27 lines (21 loc) · 896 Bytes
/
HelloWorld.java
File metadata and controls
27 lines (21 loc) · 896 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
import java.util.Scanner;
public class HelloWorld
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("What is your name?");
String name = scanner.next();
System.out.println("Nice to meet you, " + name);
System.out.println("Give me a number and i'll double it");
// Note: I can put anything I want here
Double x = scanner.nextDouble();
System.out.println("The new answer is: " + (2 * x));
//Take in two numbers from the scanner
System.out.println("Enter the first number. ");
Double y = scanner.nextDouble();
System.out.println("Enter the second number. ");
Double z = scanner.nextDouble();
//and add them together, and print the output
System.out.println("The answer is, " + (y+z));
}
}