1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Fantom [35]
3 years ago
8

For this exam review lab exercise, you will develop a program that fixes faulty data in a one-dimensional array of integers. Fau

lty data is represented by a value of 9999, and should be replaced by the average of the two neighboring elements, where integer casting should be applied to non-integer averages (to keep the data stored as integers). If the first or last element is faulty, it should be replaced by the value of its only neighboring element. If two adjacent neighboring elements are faulty anywhere in the array, a message should be printed to screen stating that the data cannot be fixed. The programming tasks have been segmented into levels. It is strongly recommended that you complete all lower level tasks before moving on to a higher level.
A code template has been provided for you that reads in data from the user and prints out the inputted data to screen. DO NOT MODIFY THE TEMPLATE CODE, INSTEAD ONLY ADD FUNCTIONALITY FOR THE LEVEL 1-3 TASKS AS DESCRIBED BELOW.
Programming Tasks
Level 0 Tasks
Simply ensure you submit a code that compiles and runs without any errors and that the functionality of the code template has not been modified. Beyond that, you don't need to do anything else to earn these points. (To be clear, submit the template right now, and you should get at least 50 points.)
Level 1 Tasks
Write the checkData() function, which takes in as parameters an integer data array, the array size, and another integer badValue. The function should return true if there are no elements in the array that contain badValue. The function should return false if the array stores badValue at any element in the array.
Call checkData() from main() to check for faulty data in the array temps. Depending on the result, print to screen either
No Faulty Data!
OR
Fixing Faulty Data...
Write the fixData() function, which has the same parameters as checkData(). The function should fix the data by replacing all elements that are badValue with the average of the two neighboring elements. For Level 1, you can assume that the first and last elements do not contain badValue and that no two consecutive elements contain badValue. The function should return the number of elements that originally stored badValue but have now been fixed.
Call fixData() from main() to fix the data in temps and print the updated array to screen using the provided printData() function.
Level 2 Tasks
Update fixData() for cases where badValue is stored in the first or last element. In these cases, replace the the faulty data with the only neighboring element. For Level 2, you can still assume that no two consecutive elements contain badValue.
Level 3 Tasks
Update fixData() for cases where badValue is stored in two consecutive elements. In these cases, return -1 to main(), where you the following message should be printed to screen (and then the program immediately terminates):
Adjacent elements are faulty. Data cannot be fixed!
For this final (Level 3+) task, print an asterisk (i.e. * ) underneath the elements of the fixed array (printed to screen in the last Level 1 Task) for all elements that originally were faulty, but have now been updated using the neighboring elements. You need to be careful with formatting here: the asterisk should go directly under the highest digit of the number.
Sample Output
Here are some sample outputs for your reference:
A code that achieves Level 1 Tasks:
Input:
12
2
9999
17
9999
-2
22
9999
4
11
9999
8
6
Output:

Enter size of data:
Enter data:
Inputted data:
2 9999 17 9999 -2 22 9999 4 11 9999 8 6
Fixing Faulty Data...
Fixed Data:
2 9 17 7 -2 22 13 4 11 9 8 6
A code that achieves Level 2 Tasks:
Input:
11
9999
17
9999
-2
22
9999
4
11
9999
8
6
Output:
Enter size of data:
Enter data:
Inputted data:
9999 17 9999 -2 22 9999 4 11 9999 8 6
Fixing Faulty Data...
Fixed Data:
17 17 7 -2 22 13 4 11 9 8 6
A code that achieves Level 3 Tasks:
Input:
10
9999
9999
-2
22
9999
4
11
9999
8
6
Output:
Enter size of data:
Enter data:
Inputted data:
9999 9999 -2 22 9999 4 11 9999 8 6
Fixing Faulty Data...
Adjacent elements are faulty. Data cannot be fixed!
A code that achieves Level 3+ Tasks:
Input:
10
9999
-2
22
9999
4
11
8
9999
7
9999
Output:

Enter size of data:
Enter data:
Inputted data:
9999 -2 22 9999 4 11 8 9999 7 9999
Fixing Faulty Data...
Fixed Data:
-2 -2 22 13 4 11 8 7 7 7
* * * *
Computers and Technology
1 answer:
Paladinen [302]3 years ago
3 0

Answer:

start with what you know

Explanation:

You might be interested in
Which file extension takes less storage space?
anyanavicka [17]

I believe the answer would be the JPEG file extension.

4 0
3 years ago
Read 2 more answers
What is the reason that a modern electron microscope (TEM) can resolve biological images to the subnanometer level, as opposed t
zhannawk [14.2K]

Answer:

The correct answer to the following question will be "The wavelengths of the electron beams are also much shorter or less than illumination and visible light".

Explanation:

TEM seems to be a methodology of microscopy during which a pulse of electrons is transferred to create the effect through some kind of microscope, could approach biological objects at the sub-nanometer standard, as related to hundreds of nano-meters for either the absolute best microscope with super-resolution.

Also because of the electron beam's distances, they are still much shorter or smaller than daylight and infrared light, meaning that biological objects and artifacts can be resolved.

6 0
3 years ago
Which section of a personal narrative requires the most development
attashe74 [19]
D. Plot because a,b,and c is consider plot can i have brainlest answer please

5 0
3 years ago
Program 4 - Pick color Class Create a class that randomly pick a color from an array of colors: string colors[7]; Have the color
xxMikexx [17]

Answer:

#include<cstdlib>

#include<bits/stdc++.h>

#include<time.h>

using namespace std;

class Colors{

string colors[7];

public:

void setElement(int,string);

void printAllColors();

void printRandomColor();

};

void Colors::setElement(int index,string color){

colors[index] = color;

}

void Colors::printAllColors(){

cout << "Printing all the colors:\n";

for(int i=0;i<7;i++){

cout << colors[i] <<"\t";

}

}

void Colors::printRandomColor(){

srand (time(NULL));

int index = rand() % 7;

cout<< "\n\nThe random picked color:";

cout << colors[index] << endl;

}

int main(){

Colors color;

color.setElement(0,"red");

color.setElement(1,"orange");

color.setElement(2,"yellow");

color.setElement(3,"green");

color.setElement(4,"blue");

color.setElement(5,"indigo");

color.setElement(6,"violet");

color.printAllColors();

color.printRandomColor();

}

to get the random color we are using srand and rand function. we are using time as seed to srand() function,because every time the time is changed. And based on that we are using rand() function and doing mod with 7 with the random number to get the index between 0 to 6, as ut array size is 7(0 to 6).

In the setElement(int index,string color) method we are inserting the value of colors in the colors array based on index.

In the printAllColors() function we are printing all the colors in the array.

In the printRandomColor() er are printing any random color based on rand() function.

and in main() we are initializing the string array with colors and calling the functions.

7 0
2 years ago
Read 2 more answers
Given that it takes 0.08 ms to travel from one track to the next of a hard drive; that the arm is originally positioned at Track
daser333 [38]

Answer:

Time taken to travel from one track to the next = 0.08ms

Initial track= 15     0

4      (15-4)*(0.08)= 0.88

40     (40-4)*(0.08)= 2.88

35      (40-35)*(0.08)= 0.4

11       (35-11)*(0.08)= 1.92

14       (14-11)*(0.08)= 0.24

7         (14-7)*(0.08)= 0.56

----------------------------------------------

Total seek time=0.88+2.88+0.4+1.92+0.24+0.56=6.88ms

Explanation:

We caculate the seek time for each request, and then add them together to find the total seek time. The final track number for the current request becomes the current track of next request, and this process is repeated till the last request is processed.

4 0
3 years ago
Other questions:
  • What is the input output ratio if its 12/23
    7·1 answer
  • Which access object(s may be used when creating a lookup field to select valu?
    8·1 answer
  • Read the paragraph.
    12·2 answers
  • Which certification can help enhance your job prospects in the role of a computer programmer?
    6·2 answers
  • Which rule should be followed to stay safe online
    5·1 answer
  • 2 ways to make your computer work faster ( please help asap )
    6·1 answer
  • Xercise 1<br>1.<br>What is system? Explain the components of system in brief.​
    12·1 answer
  • When computer network are joined together they form a bigger network called the​
    5·1 answer
  • You looked at the methods used to determine database requirements. Now, research and find a database requirements template. Choo
    9·1 answer
  • How exactly do you find the circumference by using C++ Programming? I really need a specific answer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!