Last active
May 25, 2021 16:44
-
-
Save MrRahulR/ee292b72fe4554189008ee2b90db5dd2 to your computer and use it in GitHub Desktop.
VariableDemo,java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VariableDemo { | |
public static void main(String[] args) { | |
double profit, principle = 1000, interestRate = 0.0625; // it is possible to initialize at creation time | |
int numOfYears = 5; | |
// Calculate profit after the given number of years | |
// Notice that until this point, profit is still uninitialized | |
profit = principle * interestRate * numOfYears; | |
System.out.println("The profit after " + numOfYears + " years is: " + profit + "$."); | |
} | |
} | |
/* | |
Output : The profit after 5 years is: 312.5$ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment