Tuesday, March 31, 2015

Series average for a player in three One Day Internationals

Script

#include <iostream>
using namespace std;
#include <string>
#include <cmath>

int main()
{
        string player = "";
        cout << "What is the name of the player ?  :  ";
        getline(cin,player);

        int first_ODI=0;
        cout << "How many runs did " << player << " score in the first _ODI ? : ";
        cin >> first_ODI;

        int second_ODI=0;
        cout << "How many runs did " << player << " score in the second _ODI ? : ";
        cin >> second_ODI;

        int third_ODI=0;
        cout << "How many runs did " << player << " score in the third _ODI ? : ";
        cin >> third_ODI;

        double average = (double)(first_ODI + second_ODI + third_ODI)/3;
        cout << "" << player << "'s average score for the series is " << average << ".\n\n";
        return 0;
}


Execution

What is the name of the player ?  :  Rahul Dravid
How many runs did Rahul Dravid score in the first _ODI ? : 55
How many runs did Rahul Dravid score in the second _ODI ? : 56
How many runs did Rahul Dravid score in the third _ODI ? : 57
Rahul Dravid's average score for the series is 56.


What is the name of the player ?  :  Virender Sehwag
How many runs did Virender Sehwag score in the first _ODI ? : 45
How many runs did Virender Sehwag score in the second _ODI ? : 2
How many runs did Virender Sehwag score in the third _ODI ? : 39
Virender Sehwag's average score for the series is 28.6667.


What is the name of the player ?  :  VVS Laxman
How many runs did VVS Laxman score in the first _ODI ? : 79
How many runs did VVS Laxman score in the second _ODI ? : 63
How many runs did VVS Laxman score in the third _ODI ? : 5
VVS Laxman's average score for the series is 49.


No comments:

Post a Comment