Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int[] a = {87, 6, 11, 15, 8, 4};
- // 87 87.0
- int suma = 0;
- double vidurkis;
- /* skaiciuojame masyvo elementu suma*/
- for(int i = 0; i < a.length; i++) {
- suma += a[i];
- }
- /* skaiciuojame vidurki */
- vidurkis = (double)suma / (double)a.length;
- /* apvaliname gauta rezultata */
- DecimalFormat df = new DecimalFormat("#.000");
- String rez = df.format(vidurkis);
- System.out.println(rez);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement