-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsingVariables.java
More file actions
31 lines (27 loc) · 1.05 KB
/
UsingVariables.java
File metadata and controls
31 lines (27 loc) · 1.05 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
public class UsingVariables {
/*
Project Name: Variables
Created by: Melissa B.
Created on: 15/02/2017
*/
public static void main(String[] args) {
// declaration and initialisation of variables
char letter = 'A'; // Single chars - use single quote
int num1 = 25;
double num2 = 35.67;
// Values stored in variables output to screen
System.out.println ("Value stored in letter is " + letter);
System.out.println("Value stored in num1 is " + num1);
System.out.println("Value stored in num2 is " + num2);
System.out.print("\n\n");
// Values of the variables can be changed
letter = 'B';
num1 = 157;
num2 = -157.69;
// Values stored in variables output to screen
System.out.println ("Value now in letter is " + letter);
System.out.println ("Value now in num1 is " + num1);
System.out.println ("Value now in num2 is " + num2);
System.out.print("\n\n");
}
}