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

I can\'t get this code to run. Can I get some assistance, PLEASE? #include <iost

ID: 3534436 • Letter: I

Question

I can't get this code to run. Can I get some assistance, PLEASE?



#include <iostream>

using namespace std;


//funtion prototypes

void displayMonthly(double rain[], int numElements);

void displayTotal(double rain[], int mumElements);


int main()

{

//declare array and variable

double rainfall[12] = {0.0};

int choice =0;

  

//get rainfall amounts

for (int x = 0; x < 12; x += 1)

{

cout << "Enter rainfall for month "

<< x + 1 << ": ";

cin >> rainfall[x];

} //end for

  

do

{

//display menu and get menu choice

cout << endl;

cout << "1 Display monthly amounts" << endl;

cout << "2 Display total amount" << endl;

cout << "3 end program" << endl;

cout << "Enter your choice: ";

cin >> choice;

  

//call appropriate funtion or end program

if (choice == 1)

displayMonthly(rainfall, 12);

else

if (choice == 2)

displayTotal(rainfall, 12);

//end if

//end if

} while ( choice == 1 || choice ==2);

  

system("pause");

return 0;

} //end of main function


//*****function definitions*****

void displayMonthly(double rain)[], int numElements)

{

cout << "Montly rainfall amounts:" << endl;

for (int x = 0; x < numElements; x += 1)

cout << endl;

//end for

} //end of displayMonthly function

  

void displayTotal(double rain[], int numElements)

{

double total = 0.0;

for (int x = 0; x < numElements; x += 1)

total = total + rain[x];

//end for

cout << "Total rainfall: " << total << endl;

} //end of displayTotal function

Explanation / Answer

//working code here


#include <iostream>

using namespace std;


//funtion prototypes

void displayMonthly(double rain[], int numElements);

void displayTotal(double rain[], int mumElements);


int main()

{

    //declare array and variable

    double rainfall[12] = {0.0};

    int choice          =0;

   

    //get rainfall amounts

    for (int x = 0; x < 12; x += 1)

    {

        cout << "Enter rainfall for month "<< x + 1 << ": ";

        cin >> rainfall[x];

    }   //end for

   

    do

    {

        //display menu and get menu choice

        cout << endl;

        cout << "1 Display monthly amounts" << endl;

        cout << "2 Display total amount" << endl;

        cout << "3 end program" << endl;

        cout << "Enter your choice: ";

        cin >> choice;

       

        //call appropriate funtion or end program

        if (choice == 1)

            displayMonthly(rainfall, 12);

        else

            if (choice == 2)

                displayTotal(rainfall, 12);

            //end if

        //end if

    } while ( choice == 1 || choice ==2);

   

    system("pause");

    return 0;

}   //end of main function


//*****function definitions*****

void displayMonthly(double rain[], int numElements)

{

    cout << "Montly rainfall amounts:" << endl;

    for (int x = 0; x < numElements; x += 1)

        cout <<rain[x] << endl;

    //end for

}   //end of displayMonthly function

   

void displayTotal(double rain[], int numElements)

    {

        double total = 0.0;

        for (int x = 0; x < numElements; x += 1)

            total = total + rain[x];

        //end for

        cout << "Total rainfall: " << total << endl;

    }   //end of displayTotal function

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