-
-
Save ahlens/4ce149fc5328d2b058ab1e1b8ba15888 to your computer and use it in GitHub Desktop.
SamouczekProgramisty
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
// 1. Napisz metodę pobierającą dwuelementową tablicę liczb i zwracający ich sumę. | |
Scanner scanner = new Scanner(System.in); | |
double[] exerciseArray1 = new double[3]; | |
double sum = 0; | |
System.out.println("Enter values for your array:"); | |
// Entered values are stored in array | |
for (int i = 0; i < exerciseArray1.length; i++) { | |
exerciseArray1[i] = scanner.nextDouble(); | |
} | |
for (int element = 0; element < exerciseArray1.length; element++) { | |
sum += exerciseArray1[element]; // W jaki sposób zsumować elementy, żeby wyświetliły się w jednym wyniku? | |
System.out.println(sum); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment