Last active
October 17, 2016 22:22
-
-
Save ornirus/2c5840c6526145ec81b1502c736fd03d 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
public class Average | |
{ | |
static int[] avg = {45, 56, 34, 89}; | |
static long first = 2000000; | |
static long second = 4000000; | |
public static void main(String[] args) | |
{ | |
PrintAll(); | |
PrintSum(); | |
PrintAverage(); | |
} | |
public static void PrintAll() | |
{ | |
for (int i = 0; i < avg.length; i++) { | |
System.out.println(avg[i]); | |
} | |
} | |
public static int CalSum() | |
{ | |
int ans = 0; | |
for (int i = 0; i < avg.length; i++) { | |
ans = ans + avg[i]; | |
} | |
return ans; | |
} | |
public static void PrintSum() | |
{ | |
System.out.println(CalSum()); | |
} | |
public static void PrintAverage() | |
{ | |
System.out.println(CalSum()/avg.length); | |
} | |
public static void Print() | |
{ | |
long result = first * second; | |
System.out.println(result); | |
} | |
} |
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 VolumeConversion | |
{ | |
public static final double GToL = 4.546; | |
public static double gallons = 14; | |
public static double litres; | |
public static String lit = "The number of litres in "; | |
public static String gal = " gallons is "; | |
public static void main(String[] args) | |
{ | |
litres = gallons * GToL; | |
// Complete output with appropriate text | |
System.out.println(lit + gallons + gal + litres); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment