Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct stats
- {int touchdowns;
- int max;
- int min;
- double mode;
- double mode_freq;
- double mean;
- double total;
- }
- ;
- int main()
- {
- int years;
- double count=0;
- stats player;
- cout<<"enter the touchdowns made each yeaar\n";
- cout<<"how many years do you want to put in?\n";
- cin>>years;
- stats scored[years];
- int index;
- player.max=0;
- player.mean=0;
- player.mode=0;
- player.mode_freq=1;
- for (index = 0; index < years; index++)
- {
- cout << "enter the amount of touchdowns one year" << endl;
- cin >> scored[index].touchdowns;
- player.total=player.total+scored[index].touchdowns;
- if (player.min>scored[index].touchdowns)
- { player.min=scored[index].touchdowns;
- }
- if (scored[index].touchdowns>player.max)
- { player.max=scored[index].touchdowns;
- }
- }
- do
- {
- int j=index;
- index++;
- do
- {
- if(scored[index].touchdowns==scored[j].touchdowns)
- {count=count+1;
- }
- if (count>player.mode)
- {
- player.mode=scored[index].touchdowns;
- }
- if (count>player.mode_freq)
- {
- player.mode_freq=count;
- }
- j++;
- count=0;
- }
- while(j<years);
- }
- while (index<years);
- player.mean=player.total/years;
- cout<<"touchdowns: "<<player.total<<endl;
- cout<<"the min: "<<player.min<<endl;
- cout<<"the max: "<<player.max<<endl;
- cout<<"the mode: "<<player.mode<<endl;
- cout<<"the mode freq.:"<<player.mode_freq<<endl;
- cout<<"the mean: "<<player.mean<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement