-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava.java
More file actions
72 lines (50 loc) · 1.41 KB
/
Copy pathjava.java
File metadata and controls
72 lines (50 loc) · 1.41 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
Author: Christian
Purpose: test output and input
*/
import java.util.Scanner; //used for user-input
public class HelloWorld{
//entry point of program
public static void main(String[] args){
/*
other data types
int - 3, 100, -33
double - 2.3, 0.33
char - 'x' '!' '1'
boolean - true/false
string - "word", "cat" "sdgrrerge"
*/
//declare all variables
String word = "Hello World!";
Scanner input = new Scanner(System.in);
String name = "";
int age = 0;
double gpa = 0.0;
//output Hello World!
System.out.println(word);
//prompt the user
System.out.println("What is your name?");
//get user input
name = input.next();
/*
name.lenght() //get how many characters in string
== //is equal to
*/
if(){
}
/*
to get other datatypes with scanner:
.next() - to get a String
.nextInt() - to get Int
.nextDouble() - to get double
*/
//output what user typed in
System.out.println("Hello " + name);
System.out.println("How old are you?");
age = input.nextInt();
System.out.println("you are " + age + " years old");
System.out.println("What is your gpa?");
gpa = input.nextDouble();
System.out.println("you have a " + gpa + " gpa");
}//end main
}//end class