I need some help with finding the least amount for my third function..
//Libraries
#include
#include
#include
using namespace std;
// Global constants
const int MONKEYS=3;
const int DAYS=5;
// Prototypes
void getfoodeaten ( double[][DAYS]);
void displayAvgDaily(double [][DAYS]);
void displayLeastEaten(double [][DAYS]);
int main ()
{
double total;
double average;
double food[MONKEYS][DAYS];
cout<< "Please enter the number of pounds eaten for each monkey."<
getfoodeaten(food);
displayAvgDaily(food);
displayLeastEaten(food);
return 0;
}
// Function declarations
void getfoodeaten ( double food[][DAYS])
{
for (int monkey=0; monkey< MONKEYS ; monkey++)
{
for (int day =0;day
{
cout<< "Monkey # "<<(monkey+1)<<"\t"<< "Day # " <<(day+1)<<":";
cin >> food[monkey][day];
}
}
}
// This function will display the average amount of food eaten per day by all the monkeys
void displayAvgDaily(double food[][DAYS])
{
for (int day=0;day
{
double total=0.0;
double average=0.0;
for (int monkey=0;monkey
total+=food [monkey][day];
average=total/MONKEYS;
cout << "The average amount eaten per day is: "<< (day+1) <
}
}
void displayLeastEaten(double food[][DAYS])
{
double least;
least=food[0][0];
for (int monkey=0;monkey
for (int day=0;day
if (food [monkey][day]
{
least =food [monkey][day];
least=monkey;
least=day;
}
cout<< "Lowest eaten by anyone monkey"<
least+1<<"on day "<< least<
}
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
// Global constants
const int MONKEYS=3;
const int DAYS=5;
// Prototypes
void getfoodeaten ( double[][DAYS]);
void displayAvgDaily(double [][DAYS]);
void displayLeastEaten(double [][DAYS]);
int main ()
{
double total;
double average;
double food[MONKEYS][DAYS];
cout<< "Please enter the number of pounds eaten for each
monkey."<<endl;
getfoodeaten(food);
displayAvgDaily(food);
displayLeastEaten(food);
return 0;
}
// Function declarations
void getfoodeaten ( double food[][DAYS])
{
for (int monkey=0; monkey< MONKEYS ; monkey++)
{
for (int day =0; day<DAYS; day++)
{
cout<< "Monkey # "<<(monkey+1)<<"\t"<< "Day
# " <<(day+1)<<":";
cin >> food[monkey][day];
}
cout<<endl;
}
}
// This function will display the average amount of food eaten
per day by all the monkeys
void displayAvgDaily(double food[][DAYS])
{
for (int day=0; day<DAYS; day++)
{
double total=0.0;
double average=0.0;
for (int monkey=0; monkey<MONKEYS ; monkey++)
total+=food [monkey][day];
average=total/MONKEYS;
cout << "The average amount eaten on "<<(day+1)
<<" is: "<< average<<endl;
}
}
void displayLeastEaten(double food[][DAYS])
{
// These variables will hold the monkey number who had eaten the
least
// and the day number when it was eaten least
int monkey_number = 0;
int day_number = 0;
double least;
least=food[0][0];
for (int monkey=0; monkey< MONKEYS ; monkey++)
for (int day=0; day<DAYS; day++)
if (least > food [monkey][day])
{
least = food [monkey][day];
monkey_number = monkey;
day_number = day;
}
cout<< "Lowest eaten by anyone monkey "<<(monkey_number+1)<<"on day "<<(day_number+1)<<endl;
}
OUTPUT
I need some help with finding the least amount for my third function.. //Libraries #include #include...
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();...
#include using namespace std; int main() { //declare variables and named constant int cupsPurchased =0; int platesPurchased =0; double cupPrice =0.0; double platePrice =0.0; double totalCupCost= 0.0; double totalPlateCost= 0.0; double subtotal =0.0; double totalCost =0.0; const double TAX_RATE = .055; //Enter input items cout << "Cup price: "; cin >> cupPrice; cout << "Plate price: "; cin >> platePrice; cout << "Cups purchased";...
graph binary search for size and time c++ //System Libraries #include <iostream> #include <string> #include <cstdlib> #include <ctime> #include <iomanip> #include <algorithm> using namespace std; //User Libraries //Global Constants, no Global Variables are allowed //Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc... //Function Prototypes //Execution Begins Here! int main(int argc, char** argv) { int n, i, arr[50], search, first, last, middle,count=0,count_in,tot; clock_t start, end; float duration; cout<<"Enter total number of elements :"; cin>>n; cout<<"Enter numbers"; for (i=0; i<n;i++) cin>>arr[i]; cout<<"Enter a...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
Follow the instructions for starting C++ and viewing the Intermediate23.cpp file, which is contained in either the Cpp8IChap11\Intermediate23 Project folder or the Cpp8\Chap11 folder. (Depending on your C++ development tool, you may need to open the project/solution file first.) The program uses an array to store the amount of money a game show contestant won in each of five days. The program should display the total amount won and the average daily amount won. It should also display the day...
Hello, I have written a code that I now need to make changes so that arrays are transferred to the functions as pointer variable. Below is my code I already have. #include<iostream> #include<string> #include<iomanip> using namespace std; //functions prototypes void getData(string id[], int correct[], int NUM_STUDENT); void calculate(int correct[], int incorrect[], int score[], int NUM_STUDENT); double average(int score[], int NUM_STUDENT); void Display(string id[], int correct[], int incorrect[], int score[], double average, int NUM_STUDENT); int findHigh(string id[], int score[], int NUM_STUDENT);...
I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include <string> #include <iomanip> using namespace std; struct Drink { string name; double cost; int noOfDrinks; }; void displayMenu(Drink drinks[], int n); int main() { const int size = 5; Drink drinks[size] = { {"Cola", 0.65, 2}, {"Root Beer", 0.70, 1}, {"Grape Soda", 0.75, 5}, {"Lemon-Lime", 0.85, 20}, {"Water", 0.90, 20} }; cout <<...
In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...
I NEED A PSEUDOCODE ALGORITHM FOR THIS CODE PLEASE C++: #include #include #include #include using namespace std; int NumOfEmployees(); int TotDaysAbsent(int); double AverageAbsent(int, int); int main() { cout << endl << "Calculate the average number of days a company's employees are absent." << endl << endl; int numOfEmployees = NumOfEmployees(); TotDaysAbsent(numOfEmployees); return 0; } int NumOfEmployees() { int numOfEmployees = 0; cout << "Please enter the number of employees in the company: "; cin >> numOfEmployees; while(numOfEmployees <= 0) { ...
When the user has finished entering the sales amounts, the program should display the number of sales amount entered and the average commission. #include <iostream> using namespace std; int main() { const double rate =0.2; int sales = 0; double commission = 0.0; double totalSales =0.0; cout << "First salesperson's sales (-1 to stop) : "; cin >> sales; while (sales !=-1) { commission = sales * rate; cout << "Commission : $ " << commission << endl; cout <<...