0

Help solve the task. Please, write the code

It is necessary to summarize any two numbers (double) that are entered by the user through a space

24th Apr 2018, 4:08 AM
Руслан Соколов
Руслан Соколов - avatar
3 odpowiedzi
+ 2
Have you tried to do it yet? don't forget to include the code so others can understand what your problem is. Anyways, what do you mean "through a space"?
24th Apr 2018, 5:01 AM
Ipang
+ 1
import java.util.Scanner; class MyClass { public static void main(String[] args) { // You didn't declare "array" variable // declare "array" before you use it // TIPS: To avoid confusion give your // array a descriptive name rather than // just "array". e.g. intArray int[] array = {1,2,3,4,5,6,7,8,9,10}; // You didn't declare "variable" // TIPS: To avoid confusion name the // variables by their purpose // e.g. here you can nsme it "summary" int variable = 0; for (int i = 0; i < array.length; i++) { variable += array[i]; } System.out.println("Summary of array values: " + variable); } } I see you created a Scanner in your code, but it wasn't being properly used, so I remove it in this.
24th Apr 2018, 5:41 AM
Ipang
24th Apr 2018, 5:14 AM
Руслан Соколов
Руслан Соколов - avatar