### Lab assignment

I need this code to pass one course, but i don´t know about c programming also I don´t speak English very well. If anyone can send me the solution please i will be infinetly thanked. I don't need learn programming in my career but I am not in my country. I leave here the homework and if anyone can please give me the solution. Thank you very much.

Create an array of double size 100
Repeatdly query the user with the following options

0 - Enter a new number
1 - Modify an existing number
2 - Search for a number
3 - Compute min and max
4 - Compute arithmetic mean
5 - Compute standard deviation
6 - Print all numbers
7 - Quit

Mantain a count of all numbers entered so far
New numbers must be entered at the end of numbers
When searchin, find all occurrences of a number

Like this? I haven't tested this so I'm pretty sure there's a bug or two in it.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132`` ``````#include int menu() { int menu_selection; std::cout << "0 - Enter a new number\n" << "1 - Modify an existing number\n" << "2 - Search for a number\n" << "3 - Compute min and max\n" << "4 - Compute arithmetic mean\n" << "5 - Compute standard deviation\n" << "6 - Print all numbers\n" << "7 - Quit" << std::endl; std::cin >> menu_selection; return menu_selection; } void search(double searcher, double* arr, int size) { for (int i = 0; i < size; ++i) if (arr[i] == searcher) std::cout << searcher << " found at pos " << i << std::endl; } double min(double* arr, int size) { double worker = arr[0]; for (int i = 1; i < size; ++i) if (arr[i] < worker) worker = arr[i]; return worker; } double max(double* arr, int size) { double worker = arr[0]; for (int i = 1; i < size; ++i) if (arr[i] > worker) worker = arr[i]; return worker; } double mean(double* arr, int size) { double worker = 0.; for (int i = 0; i < size; ++i) worker += arr[size]; return worker/(double(size)); } double stdev(double* arr, int size) { double Mean = mean(arr,size); double sum = 0; for (int i = 0; i < size; ++i) sum += (arr[i]-Mean)*(arr[i]-Mean); return sqrt( sum / (double(size)) ); } void print(double* arr, int size) { for (int i = 0; i < size; ++i) std::cout << arr[i] << ' '; } int main() { double numbers[100]; int number_size = 0; while(true) { switch ( menu() ) { case 0: { std::cout << "Enter your number: "; std::cin >> numbers[number_size++]; break; } case 1: { int index; std::cout << "Which index?: "; std::cin >> index; std::cout << "What number?: "; std::cin >> numbers[ index ]; break; } case 2: { double searcher; std::cout << "Which number?: "; std::cin >> searcher; search(searcher, numbers, number_size); break; } case 3: { std::cout << "min/max: " << min(numbers,number_size) << '/' << max(numbers,number_size) << std::endl; break; } case 4: { std::cout << "mean: " << mean(numbers, number_size) << std::endl; break; } case 5: { std::cout << "stdev: " << stdev(numbers,number_size) << std::endl; break; } case 6: { print(numbers,number_size); break; } case 7: { return 0; } default: { std::cout << "Wrong input" << std::endl; break; } } } }``````
Last edited on
Thank you very very much, you are a lifesaver. I will test it and find the bugs (If there are any)
Topic archived. No new replies allowed.