Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to randomly generate integer data values into an array that can hold 25 values. The program should ask the user to enter

  1. Write a program to randomly generate integer data values into an array that can hold 25 values. The program should ask the user to enter the minimum and maximum values in a numeric range that is not less than 1 and not greater than 500. Validate that the user enters the numbers correctly (minimum first >= 1 and then maximum <= 500) and correct the errors if not. The program should then generate 25 random numbers in that range and store them in the array. After filling the array, the program should calculate the total of all the values that are even numbers and the total of all the values that are odd numbers. Then the program should calculate the square root of each of those totals (hint: math library function). Display all 25 values in the array. Display the total of the even numbers and the square root of that total. Display the total of the odd numbers and the square root of that total. 

  2. Required Functions: 

  3. A function that reads and validates the minimum and maximum values that the user enters. This will require reference parameters in order to return both values to the function call.
  4. A function that can generate random numbers in a sequential range and return the number generated. This function should be able to work with any sequential range of numbers not specific to this program.
  5. A function that will calculate the total of the even numbers and the total of the odd numbers in the array. This function will have to use two parameters passed by reference to store the totals. The function will also need an array parameter that cannot be modified in the function. The function will also need a parameter to store the size of the array which cannot be modified in the function. A function to display the array.

Step by Step Solution

3.46 Rating (159 Votes )

There are 3 Steps involved in it

Step: 1

import random import math def main size 25 start end rangeinput numarr arraygenstart end size ev... 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

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions

Question

What attracts you to our graduate program specifically?

Answered: 1 week ago