Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement Output the sum of the squares of all the odd integers between firstNum and secondNum where firstNum and secondNum are entered by the

image text in transcribed

Problem Statement Output the sum of the squares of all the odd integers between firstNum and secondNum where firstNum and secondNum are entered by the user. For example, if 3 and 9 were entered for firstNum and secondNum, respectively, the output would be 32 5 72 92 164 (you only have to output 164). If 2 and 10 were entered for firstNum and secondNum, respectively, the output would still be 164 Input Data firstNum . secondNum Output Data .Sum of the squares of all the odd integers between firstNum and secondNum. Algorithm 1. 2. 3. Clear the Command Window and Workspace windows Prompt for firstNum and secondNum If firstNum is greater than or equal to secondNum, display error message The first number must be less than the second number! Otherwise Initialize sum to 0 First use a for-loop to calculate and display the sum of the squares of all the odd numbers within the range Then use a while-loop to do the same thing 4. 5. 6. Sample Output Enter the first number: 3 Enter the second number: 9 The sum of the squares of all odd numbers between 3 and 9 is (for loop): 164 The sum of the squares of all odd numbers between 3 and 9 is (while loop): 164 2D Enter the first number: 2 Enter the second number: 10 The sum of the squares of all odd numbers between 2 and 10 is (for loop): 164 The sum of the squares of all odd numbers between 2 and 10 is (while loop): 164 2P Enter the first number: 8 Enter the second number: 2 The first number must be less than the second number! >2 7. Before each significant step, provide a comment explaining the step (do not comment every line of code). Problem Statement Output the sum of the squares of all the odd integers between firstNum and secondNum where firstNum and secondNum are entered by the user. For example, if 3 and 9 were entered for firstNum and secondNum, respectively, the output would be 32 5 72 92 164 (you only have to output 164). If 2 and 10 were entered for firstNum and secondNum, respectively, the output would still be 164 Input Data firstNum . secondNum Output Data .Sum of the squares of all the odd integers between firstNum and secondNum. Algorithm 1. 2. 3. Clear the Command Window and Workspace windows Prompt for firstNum and secondNum If firstNum is greater than or equal to secondNum, display error message The first number must be less than the second number! Otherwise Initialize sum to 0 First use a for-loop to calculate and display the sum of the squares of all the odd numbers within the range Then use a while-loop to do the same thing 4. 5. 6. Sample Output Enter the first number: 3 Enter the second number: 9 The sum of the squares of all odd numbers between 3 and 9 is (for loop): 164 The sum of the squares of all odd numbers between 3 and 9 is (while loop): 164 2D Enter the first number: 2 Enter the second number: 10 The sum of the squares of all odd numbers between 2 and 10 is (for loop): 164 The sum of the squares of all odd numbers between 2 and 10 is (while loop): 164 2P Enter the first number: 8 Enter the second number: 2 The first number must be less than the second number! >2 7. Before each significant step, provide a comment explaining the step (do not comment every line of code)

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions