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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started