public class ex417a{ public static void main(String[] args) { int i, sum = 0; i = 1; while (i <= 10) { sum += i; i++; } System.out.println("Sum of 1 through 10 = " + sum); }4-17b. Update 4-17a (which is attached) that summed the numbers 1 through 10 to get XXXXXXXXXX XXXXXXXXXX = 55) in a while loop. Now let the user tell what number to start counting at, what number to stop counting at, and what amount to go up each number. For example, if the user wants to start at 7, go up to 19, by 4s, you will add 7 + 11 + XXXXXXXXXX = 52 in a loop. Declare three variables (for starting number, ending number, and amount to count by) and your Scanner object and then prompt and input the three numbers from the user. Then modify the while loop into a for loop with the three parts for the start, end, and update amount, and the final print. Save as ex417b.java, run with starting at 7, going up to 19, by 4s, save the output console as ex417b.txt, attach the ex417b.java and ex417b.tx, and submit them.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here