-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsingVariables.java
More file actions
43 lines (38 loc) · 2.08 KB
/
UsingVariables.java
File metadata and controls
43 lines (38 loc) · 2.08 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
/*
*********************************************************************************
* dev23jjl DLM: 9/21/2022 UsingVariables.java
*
* Description: These are the basic required components of a simple Java program
* The program prints "Skeleton Code!" to the screen as a string literal, declares
* and initializes three variables, manipulates the data values within those
* variables by using arithmetic operators to change the values held by the
* variables, and prints the contents of the variables to the terminal.
*
*********************************************************************************
*/
public class UsingVariables {
public static void main(String[] myVar)
{
// Initialize the three variables
int myAge = 17;
int yourAge = 24;
int totalAge = 0;
// This prints out the variables in a way that can be understood by humans
// Warning: This is comical and conversational and probably not accurate...
System.out.println("I am " + myAge + " years old!");
System.out.println("Are you " + yourAge + " years old?");
System.out.println("This Java program currently thinks that our total age altogether is " + totalAge + " years.");
System.out.println("But, we'll change that...");
System.out.println("********************************************************************************************");
// Changes totalAge to add myAge and yourAge
totalAge = myAge + yourAge;
// Prints out the updated variable "totalAge" (in a conversational manner)
System.out.println("Now that we changed a few things, our age combined is " + totalAge + " years!");
System.out.println("That is a long time!");
System.out.println("******************************************************************************");
// And last but not least for randomness, we will print out "Skeleton Code!"
System.out.println("This is");
System.out.println("Skeleton Code!");
System.out.println("For using simple variables!");
}
}