Question: Hello, Please write code in # Java: Lab6C: Well, thats an odd question! The final loop we are going to practice using for this lab
Hello,
Please write code in # Java:
Lab6C: Well, thats an odd question! The final loop we are going to practice using for this lab is a for loop. Write a program that prompts the user to enter two positive numbers. The program will add all of the odd numbers in between the two inputted values and return the sum. The program must work even if the starting number is larger than the ending number. Hint: Compare a loop that counts up to a loop that counts down. Whats the difference? Start by getting sample output #1 and #2 working, then work on #3. A sample run is shown below. User input is in bold. Sample output #1: Enter a starting number: 3 Enter an ending number: 7 Sum of odds is: 15 Sample output #2: Enter a starting number: 10 Enter an ending number: 20 Sum of odds is: 75 Sample output #3: Enter a starting number: 20 Enter an ending number: 10 Sum of odds is: 75
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
