Question

What are the 8 errors in this C++ program below: /* CSE 100 Professor Feng Learn...

What are the 8 errors in this C++ program below:

/*

CSE 100 Professor Feng
Learn to read data from user and fill a two-dimensional array.
Learn how to compute the sum of one row or one column in a 2D array
Learn how to compute the sum, average of a 2D array
*/

#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

double bananaMon=0; //Global Variables to be used in the program
double bananaSat=0;
double totalSum=0.0; //Global variable total sum

double findGroupTotal(); //Prototype functions
double findLeastAmtFood();
int main()

{
int lbsFood[3][7]; //2D Declaration for 3x7 array for pounds of bananas eaten
for(int row=0; row<3; row++)
{
cout<<"Enter the pounds of bananas eaten by each monkey daily:"<<endl;
for(int column=0; column<7; column++)
{
cout<<" day "<<column+1<<" :";
cin>>lbsFood[row][column];
}

cout<<"The average amount of food eaten per day byt the entire monkey family ="; //Prompt to the user to input data for average calculation
cout<<findGroupTotal(sum/3<<" lbs." ;

cout<<"The Least amount of food eaten by any one monkey is: "<<findLeastAmtFood(lbsFood[row][column])<<endl;

for(int row=0; row<3; row++)
{
double sum=0.0;
for(column=0; column<7; column++)
{
sum=sum+monkey[row][column];

}
cout<<"Monkey number:" <<i+1<<"eat a total of "<<sum<<" lbs. of food in this week";

for(int row; row<3;row++)
{
bananaMon=bananaMon+lbsFood[row][1];
bananaSat=bananaSat+lbsFood[row][6];

}
cout<<"The monkeys eat an average of: "<<bananaMon<<endl;
cout<<" The monkeys eat an average of :"<<bananaSat<<endl;
return 0;
}


double findGroupTotal(double lbsFood[][7])
{

double sum = 0.0; //Local variable


for(int row=0; row<3; row++)
{ for (int column=0; column<7; column++)
sum = sum+ lbsFood[row][column];
}
return sum;
}

double findLeastAmount(double lbsFood[][7])

for(row=0; row<3; row++)
{
if(findLeastAmtFood>lbsFood[row][column])
{
least=lbsFood[row][column];
}
return leastAmount;
}
}

}

erros given by codeblocks:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp||In function 'int main()':|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|37|error: 'sum' was not declared in this scope|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|39|error: name lookup of 'column' changed for ISO 'for' scoping [-fpermissive]|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|39|note: (if you use '-fpermissive' G++ will accept your code)|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|39|error: too many arguments to function 'double findLeastAmtFood()'|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|22|note: declared here|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|46|error: 'monkey' was not declared in this scope|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|49|error: 'i' was not declared in this scope|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|68|error: a function-definition is not allowed here before '{' token|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|92|error: expected '}' at end of input|
C:\Users\jesse\OneDrive\Desktop\ASSIGNMENT#8\ASSIGNMENT#8.cpp|92|error: expected '}' at end of input|
||=== Build failed: 8 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Updated C++ Program:

/*

CSE 100 Professor Feng
Learn to read data from user and fill a two-dimensional array.
Learn how to compute the sum of one row or one column in a 2D array
Learn how to compute the sum, average of a 2D array
*/
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;
double bananaMon=0; //Global Variables to be used in the program
double bananaSat=0;
double totalSum=0.0; //Global variable total sum
int findGroupTotal(int lbs[][7]); //Prototype functions
int findLeastAmount(int lbs[][7]);

int main()
{
int lbsFood[3][7]; //2D Declaration for 3x7 array for pounds of bananas eaten
for(int row=0; row<3; row++)
{
cout<<"\nEnter the pounds of bananas eaten by each monkey daily:"<<endl;
for(int column=0; column<7; column++)
{
cout<<" day "<<column+1<<" :";
cin>>lbsFood[row][column];
}
}

cout<<"\n\nThe average amount of food eaten per day by the entire monkey family: ";
cout<<(findGroupTotal(lbsFood)/21.0)<<" lbs." ;

cout<<"\n\nThe Least amount of food eaten by any one monkey is: "<<findLeastAmount(lbsFood)<<endl;

for(int row=0; row<3; row++)
{
int sum=0.0;
for(int column=0; column<7; column++)
{
sum=sum+lbsFood[row][column];
}
cout<<"\nMonkey number:" <<row+1<<"eat a total of "<<sum<<" lbs. of food in this week";
}

for(int row=0; row<3;row++)
{
bananaMon=bananaMon+lbsFood[row][1];
bananaSat=bananaSat+lbsFood[row][6];
}

cout<<"\nOn Monday, The monkeys eat an average of: "<<bananaMon/3.0<<endl;
cout<<"\nOn Saturday, The monkeys eat an average of :"<<bananaSat/3.0<<endl;

return 0;
}

int findGroupTotal(int lbsFood[][7])
{
int sum = 0.0; //Local variable

for(int row=0; row<3; row++)
{
for (int column=0; column<7; column++)
sum = sum+ lbsFood[row][column];
}
return sum;
}

int findLeastAmount(int lbsFood[][7])
{
int least = lbsFood[0][0];
for(int row=0; row<3; row++)
{
for(int column=0; column<3; column++)
{
if(least>lbsFood[row][column])
{
least=lbsFood[row][column];
}
}
}
return least;
}

___________________________________________________________________________________________________

Sample Run:

Add a comment
Know the answer?
Add Answer to:
What are the 8 errors in this C++ program below: /* CSE 100 Professor Feng Learn...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help finding the error in my code for my Fill in the Blank (Making a Player Class) in C++. Everything looks good...

    I need help finding the error in my code for my Fill in the Blank (Making a Player Class) in C++. Everything looks good to me but it will not run. Please help... due in 24 hr. Problem As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. Currently, there is a test...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • Question 1) Suppose a program has the following code: const int X = 2, Y =...

    Question 1) Suppose a program has the following code: const int X = 2, Y = 3; int sum; int values[X][Y] = {{1, 2, 3},                                  {4, 5, 6}}; for(int i=0; i<X; i++) {      sum=0;      for(int j=0; j<Y; j++)         sum+=values[i][j];    cout<<sum<<endl; } What is this program getting the sum of? Group of answer choices D-) The columns of the 2D array C-) The rows of the 2D array A-) All of the elements of the 2D...

  • Find and fix the errors in this C++ code: * This program illustrates a variety of...

    Find and fix the errors in this C++ code: * This program illustrates a variety of common loop errors. * Fix the errors in each section. */ #include <iostream> using namespace std; int main() { cout << "Welcome to Loop World" << endl; // SECTION I: update comment below on how you fixed this section's code, and tests run // FIX = // TESTS: cout << endl; cout << "******************" << endl; cout << "Section I" << endl; cout <<...

  • //CODE 16-02.cpp //Demonstrates a template function that implements //a generic version of the selection sort algorithm....

    //CODE 16-02.cpp //Demonstrates a template function that implements //a generic version of the selection sort algorithm. #include <iostream> using std::cout; using std::endl; template<class T> void sort(T a[], int numberUsed); //Precondition: numberUsed <= declared size of the array a. //The array elements a[0] through a[numberUsed - 1] have values. //The assignment and < operator work for values of type T. //Postcondition: The values of a[0] through a[numberUsed - 1] have //been rearranged so that a[0] <= a[1] <=... <= a[numberUsed -...

  • Consider the following C++code snippet and what is the output of this program? # include<iostream> using...

    Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...

  • What is the output from each of the following segments of C++ code? Record the output...

    What is the output from each of the following segments of C++ code? Record the output after the “Answer” prompt at the end of each program fragment. Assume all variables have been suitably declared. (Each problem is worth 3 points.) 1. for (int j = 25; j > 16; j -= 3)        cout << setw(5) << j;     Answer: 2. int sum = 0;       for (int k = -2; k <= 2; k++)         sum = sum +...

  • Flow chart of this program #include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0,...

    Flow chart of this program #include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0, ave-ee, int locmx, locmn int n; cout <<"Enter the number of students: "<<endl; cin >> ni double listln]; double max-0; double min-e; for (int i-e ; i<n ;i++) cout<s enter the gpa: "<cendli cin>>listli]; while (listlile i listli1>4) cout<s error,Try again "<cendl; cin>listlil: sun+=list[i]; N1 if (listli]>max) for(int isin itt) max=list [i]; 10cmx=1+1 ; else if (list [i] min) min=list [i]; locmn-i+1; ave sum/n;...

  • I'm not getting out put what should I do I have 3 text files which is...

    I'm not getting out put what should I do I have 3 text files which is in same folder with main program. I have attached program with it too. please help me with this. ------------------------------------------------------------------------------------ This program will read a group of positive numbers from three files ( not all necessarily the same size), and then calculate the average and median values for each file. Each file should have at least 10 scores. The program will then print all the...

  • please help with the operator overloading lab (intArray) in c++ will provide what it is being...

    please help with the operator overloading lab (intArray) in c++ will provide what it is being required and the code that was given from the book. the code that was provided is below ------------------------------------------------------------------------------------------------------------------------- // iadrv.h #ifndef _IADRV_H #define _IADRV_H #include "intarray.h" int main(); void test1(); void test2(); void test3(); void test4(); void test5(); void test6(); void test7(); void test8(); void test9(); void test10(); void test11(); void test12(); void test13(); void test14(); void test15(); void test16(); void test17(); void test18();...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT