Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago