int main() { // Create a die Dice die; // Roll the die and print the result cout << "Die rolls a " << die.roll() << endl; // Print the average of 4 rolls cout << "4 roll avg: " << die.average(die, 4) << endl; // Declare an array of integers int rolls[5] = { 2,4,6,1,3 }; // Find the average of the values in the array cout << "5 int avg: " << die.average(rolls, 5) << endl; }
int main() { Dice X; int num = 5; int size_arr = 4; float sum = 0; float av_holder_roll = 0; float av_holder_arr; int arr[5]; //X.input(num); av_holder_roll = X.average(X,num); //Calculated and returned die roll average cout << "Enter the values for your array: " << endl; for (int j = 0; j < (size_arr); j++) { cin >> arr[j]; } av_holder_arr = X.average(arr, size_arr); //Calculated and returned array average cout << "The number of die rolls is " << num << endl; cout << "The average of the rolled values is: " << endl; X.print(av_holder_roll); cout << "The values in the array are: " << endl; for (int i = 0; i < 4; i++) { cout << arr[i] << ", "; } cout << "" << endl; cout << "The average of the values in the array is: " << endl; X.print(av_holder_arr); return 0; }