Question: JAVA would like to know how to a statement within that for loop that does not declare a variable or modify a control variable int

JAVA would like to know how to a statement within that for loop that does not declare a variable or modify a control variable int number = 2 * i + 1; int sum = 0; //prompt message to enter in value for n System.out.println(Please enter in a positive integer); n = input.nextInt(); cleanUpStr = input.nextLine(); //while loop to validate positive number while(n < 0) { System.out.println(Please enter a positive value); n = input.nextInt(); cleanUpStr = input.nextLine(); }//end while loop //for loop used to compute the sum of odd numbers for(i = 0; i < n; i++) { //calculate the numbers int number = 2 * i + 1; System.out.println(number); sum+= number; } //display sum System.out.println(The sum is +sum);

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!