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]
2 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]2 years ago
3 0

Answer:

start with what you know

Explanation:

You might be interested in
Whatis NOT a key factor while designing a website?
Vaselesa [24]

Answer: Complexity

Explanation: Web designing is referred as the designing of a web page for different purposes such as online business,etc. The most important factor is usability for the improvement in performance of any site and keeping it successful.

It should be user friendly so that interaction and understanding between user and web page can easy.Consistency is also a feature which ensure that web page opened in any browser should have similar quick working.

But there should be no complexity present in the web design which can cause misunderstand with the user and functioning.

7 0
2 years ago
A drink costs 3 dollars. A pizza costs 6 dollars. Given the number of each, compute total cost and assign to totalCost. Ex: 2 dr
steposvetlana [31]

I think it's correct

.

.

.

.

.

.

.

.

.

5 0
2 years ago
If you often purchase items at the same e-tailer and do not have to type in your username and/or password, this probably means
tatyana61 [14]

Answer:

Explanation:

This probably means that your browser has saved your username and password into the browser's password manager. This usually occurs the first time you enter your username and password into a new website. The browser will detect this and request to save this information into the password manager. If you agree to do so it will save it and automatically enter this information when opening the site in the future.

3 0
2 years ago
Need answer ASAP
kaheart [24]

Answer:

D. To ensure that the software adheres to technical standards

Explanation:

The responsibility of the software architect is to ensure that all parts of the software system are able to meet the requirements set forth by the project or specifications, in this case, the technical standards.  This is an important piece of the software system because without it, the software system may not perform the necessary functions that it was written to do.

Cheers.

5 0
2 years ago
Why is Apple using social media ?
jeka57 [31]

Apple uses social media to promote their products and increase user-engagement. This is a very effective method of advertising.

6 0
3 years ago
Other questions:
  • Pseudocode is an improvement over the IPO chart because it lays out the a0 sequence of steps for a particular program.
    6·1 answer
  • Provide the definition for each of the following structures and unions:
    8·1 answer
  • Dang was accepted to a biology program with a rigorous schedule and a high tuition, but good professors. What would be a benefit
    10·2 answers
  • The length property of the String object returns
    15·1 answer
  • Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
    15·1 answer
  • C:\windows\system32\drivers\etc\protocol is an example of a file ________. select one:
    5·1 answer
  • When measuring processor speed,a megahertz is much faster than a gigahertz.true or fals
    12·1 answer
  • Declare a typedef struct named jumper_t that will have four parts: character array name that is 16 in length, double array of tr
    12·1 answer
  • PLEASE I NEED HELP FAST
    8·1 answer
  • Find 10 real world challenges and their corresponding solutions
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!