Created
December 4, 2019 18:57
-
-
Save MkDierz/5ab425b9612378dc94856d7fa0ff6a8c to your computer and use it in GitHub Desktop.
java array declaration, find max min and total
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 static void main(String[] args) { | |
int [] data = {3, 2, 0, 8, 10, 15, 13, 6}; | |
int max = 0, min = 0, total = 0; | |
for(int i = 0; i < data.length; i++) | |
{ | |
if (max < data[i]) { | |
max = data[i]; | |
} | |
if (min > data[i]) { | |
min = data[i]; | |
} | |
total = total + i; | |
} | |
System.out.println("max = " + max); | |
System.out.println("min = " + min); | |
System.out.println("total = " + total); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment