Question: In java Lab6C: Well, that's an odd question! The final loop we are going to practice using for this lab is a for loop. Write

In java

In java Lab6C: Well, that's an odd question! The final loop we

Lab6C: Well, that's 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. What's 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

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!