Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The astronauts have a special machine that measures solar radiation every hour. The machine, however, sometimes malfunctions. When it does, it gives a reading
The astronauts have a special machine that measures solar radiation every hour. The machine, however, sometimes malfunctions. When it does, it gives a reading of 85000. Astronauts must ignore these values. Write a C++ program that helps the astronauts clean up the readings. Declare a function void CleanReadings(int weights[], int size) which takes an integer array and its size, and replaces all array elements that have the value 85000 with the average of the previous and next elements. For example, if weights[2] is 85000, then it should be replaced with (weights[1]+weights[3])/2. If the element is the first or last in the array, it should replace it with a copy of the element after or before, respectively. For example, if weights[0] is 85000, then it should be replaced with the value of weights[1]. Assume the machine never malfunctions twice in a row. In the main, declare an array of size 5 and initialize it via user input, then call the function. Print the cleaned array in the main. Sample output 1: Please input 5 radiation values 243 906 489 85000 321 The readings after data cleaning are: 243 906 489 405 321 Sample output 2: Please input 5 radiation values 85000 342 543 890 85000 The readings after data cleaning are: 342 342 543 890 890
Step by Step Solution
★★★★★
3.43 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Code include using namespace std void CleanReadingsi...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