Question: 2) Write a Java statement to accomplish each of the following tasks: Declare variables sum of type int and initialize it to 0. Declare variables

2) Write a Java statement to accomplish each of the following tasks:

Declare variables sumof type intand initialize it to 0.

Declare variables x of type intand initialize it to 1.

Add variable xto variable sum, and assign the result to variable sum.

Print The sum is: , followed by the value of variable sum.

3)

Combine the statements that you wrote in Problem 2 into a Java application that calculates and prints the sum of the integers from 1 to 10. Use a whilestatement to loop through the calculation and increment statements. The loop should terminate when the value of xbecomes 11.

PLEASE KINDLY ANSWER JUST QUESTION 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!