Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Task 1: Use Ctt Write a program in C++ that uses an array to find the Average of

ID: 3730139 • Letter: T

Question

Task 1: Use Ctt Write a program in C++ that uses an array to find the Average of a set float values entered by the user You will have the main function control the operation of the program, but all values will be stored in the class. You will need to use get and set methods in your class Create an array as a member of the class. Create a method that will generate 1000 random floats (between 1-100) No decimal valuables Create 1 method to sum all numbers in array Create 1 method to output the average of all numbers. Create 1 method to output all the numbers input by the user Hard Code a Binary Search Method and allow the user to input a value to search for. Output if the value exist in the array. If the value exist in array output the location in the array · · . . . . .Create a menu to control your program. Give the user the option to choose the operation to perform. Make sure there is a choice to select Fill Array, all through the array will be filled with random Create and implement isEmpty helper method", if the user decides to search for a number, output average, etc. before there are values inside of the array. The program should prompt the user to say "Array is empty." Attach Snipping photos of source code and output. Please show output of new methods executing. . .

Explanation / Answer

#include <iostream>

using namespace std;

class testFloat{

            float arr[1000];

            testFloat(){}

           

            void fillArray(){

           

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

                                    arr[i] = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/100));

                        }

           

            }

           

            float sumArray(){

                        float sum=0;

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

                                    sum+= arr[i];

                        }

           

                        return sum;

            }

           

           

            float avgArray(){

           

                        return (this.sumArray()/1000);

           

            }

           

            void displayArray(){

           

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

                                    cout<<arr[i]<<endl;

                        }

           

            }

}

int main() {

            int choice;

            testFloat f;

            while(choice != 5){

            cout<<"MENU"<<endl;

            cout<<"1. Fill Array"<<endl;

            cout<<"2. Sum of Array"<<endl;

            cout<<"3. Average of Array"<<endl;

            cout<<"4. Display Array"<<endl;

            cout<<"5. QUIT"<<endl;

            cin>>choice;

           

            switch(choice){

            case 1: f.fillArray(); break;

            case 2: cout<<"Sum of the array elements is: "<<f.sumArray()<<endl; break;

            case 3: cout<<"Average of the array elements is: "<<f.avgArray()<<endl; break;

            case 4: cout<<"Array elements: "<<endl<<f.displayArray()<<endl; break;

            case 5: return 0;

            default: cout<<"Enter a valid choice"<<endl;

            }

            }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote