for calculation, you are using two loops and one statment. You can actually shorten that to only one loop by checking for negative numbers (which mean array out of bounds here). for example:
|
Code:
|
if(vs1-i<0)
a = 0;
else
a = vArray1[vs1-i];
//and the same for b
// then
int sum = a + b + c;
... |
And I would suggest breaking it down to small manageable methods:
getInput()
add()
write()
edit:
also in the input, how do you plan to handle negative values?