Created
November 17, 2013 23:32
-
-
Save LordNairu/7519797 to your computer and use it in GitHub Desktop.
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
package qub.ac.uk.practical.week5; | |
public class PracticalFiveQuestionTwo { | |
public static void main(String[] args) { | |
// Declaring vars | |
double average; | |
average = 0.0; | |
// Populating array with temps | |
double [] tempArray = { 3.4, 4.2, 9.0, 2.2, 4.5, 6.4, 3.1 }; | |
// Foreach on Array to calculate average | |
for (double avgTemp : tempArray) | |
{ | |
average += avgTemp/tempArray.length; | |
} | |
// Printing average | |
System.out.println(Math.round(average*100.0)/100.0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment