Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions