Answer:
Check the explanation
Step-by-step explanation:
#include <iostream>
#include<vector>
using namespace std;
int main()
{
//declaration
vector<double> weights;
double weight,totalWeight=0,avgWeight,maxWeight;
//reading data from console
for(int i=0; i<5; i++)
{
cout<<"Enter weight "<<i+1<<": ";
cin>>weight;
weights.push_back(weight);
}
//caliculating max total and average weight and printing the weights
maxWeight=weights.at(0);
cout<<"You entered: ";
for(int i=0; i<5; i++)
{
totalWeight+=weights.at(i);
if(weights.at(i)>maxWeight)
maxWeight=weights.at(i);
cout<<weights.at(i)<<" ";
}
avgWeight=totalWeight/5.0d;
cout<<"\\Total weight: "<<totalWeight<<endl;
cout<<"Average weight: "<<avgWeight<<endl;
cout<<"Max weight: "<<maxWeight<<endl;
return 0;
}
OUTPUT: