Question
Write a program that uses while loops to perform the following steps. a. Prompt the user to input two positive integers (no zero or negative).
Write a program that uses while loops to perform the following steps.
a. Prompt the user to input two positive integers (no zero or negative). variables: firstNum and secondNum (firstNum must be less than secondNum). Validate the user's input; prompt the user again if firstNum is not less than secondNum (use while loop).
b. Output all odd numbers between firstNum and secondNum. (use while loop).
c. Output the sum of all even numbers between firstNum and secondNum. (use while loop).
d. Output the sum of the square of the odd numbers between firstNum and secondNum. (use while loop)
OUTPUT:
- The bold text is the user's input.
Enter two positive integer numbers. First number must be less than the second number: Enter numbers: 8 a Incorrect Input. Please try again. Enter two positive integer numbers. First number must be less than the second number: Enter numbers:
--------------------------------------------------------------------------------------
Enter two positive integer numbers. First number must be less than the second number you enter Enter numbers: 11 15 Odd integers between 11 and 15 are: 11 13 15 Sum of even integers between 11 and 15 = 26 Sum of the squares of odd integers between 11 and 15 = 515 Do you want to repeat this program? y/n > n Bye!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started