63 126
Assignments Done
99%
Successfully Done
In July 2018

Answer to Question #33426 in Java | JSP | JSF for Jimbo

Question #33426
Write a program that computes the sum of the first ten positive integers,
1 + 2 + • • • + 10. Write a program of the form
public class Sum10
{
public static void main(String[] args)
{
System.out.println();
}
}
Expert's answer
//Write a program that computes the sum of the first tenpositive //integers,
//1 + 2 + • • • + 10.
public class Sum10
{
public staticvoid main(String[] args)
{
System.out.println(sum(1,10));
}

public staticint sum(int start, int end)
{
int res=0;
for (int i = start; i <= end; i++)
{
res+=i;
}

return res;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions