CSC1310: lab 7C++ standard template library vector class

$30.00 $24.00

what should this program do? (specifications) Write a program that can be used to gather statistical data about the number of hours college students spend watching streaming videos on Netflix in one month. Create a vector of integers. Call a function called getStudentData to allow the user to enter the number of hours each student…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

what should this program do? (specifications)

Write a program that can be used to gather statistical data about the number of hours college students spend watching streaming videos on Netflix in one month.

  1. Create a vector of integers.

  2. Call a function called getStudentData to allow the user to enter the number of hours each student spent watching Netflix. Allow the user to continue entering in data into the vector until they enter -1 to indicate they want to quit entering in data.

Enter the number of hours each student spent watching Netflix.

Enter -1 when you are finished entering student data.

Student 1: 4

Student 2: 6

Student 3: 18

Student 4: 24

Student 5: -1


  1. Call a function called sort to sort the hours in ascending order. Use whatever sort algorithm you want. (I used insertion sort). Print a message to the screen that you are sorting the vector and tell which algorithm you used.

Sorting the vector with the Insertion Sort algorithm.


  1. Call a function called print to print out the hours in the vector.

Hours each student watched Netflix in ascending order: 4 6 18 24


  1. Call a function called getAverage to calculate the average, which should be returned from this function. Display the average to the screen.

NETFLIX STATISTICS

Average: 13.00


  1. Call a function called getMedian to calculate and display the median of the hours entered.

Median: 12.00


  1. 10 points EXTRA CREDIT! You only have to do this part of the code if you want the extra credit. Call a function called getMode to calculate the mode, which should be returned from this function. The mode is the value in the vector that occurs the most often. If the vector has no mode (none of the values occur more than once), the function should return -1. Display the mode of the hours entered or display “there is no mode” if the function returned -1.

Mode: there is no mode.


OR

Mode: 14

What to turn in

Lab7.cpp

Sample Output One

Note: my sample output contains the mode. This is extra credit (optional).

Enter the number of hours each student spent watching Netflix.

Enter -1 when you are finished entering student data.

Student 1: 99

Student 2: 14

Student 3: 24

Student 4: 10

Student 5: 5

Student 6: 0

Student 7: 6

Student 8: 50

Student 9: 14

Student 10: 28

Student 11: 7

Student 12: 17

Student 13: 14

Student 14: 99

Student 15: 18

Student 16: 27

Student 17: -1

Sorting the vector with the Insertion Sort algorithm.

Hours each student watched Netflix in ascending order: 0 5 6 7 10 14 14 14 17 18 24 27 28 50 99 99

NETFLIX STATISTICS

Average: 27.00

Median: 15.50

Mode: 14

Sample Output Two

Note: my sample output contains the mode. This is extra credit (optional).

Enter the number of hours each student spent watching Netflix.

Enter -1 when you are finished entering student data.

Student 1: 4

Student 2: 6

Student 3: 18

Student 4: 24

Student 5: -1

Sorting the vector with the Insertion Sort algorithm.

Hours each student watched Netflix in ascending order: 4 6 18 24

NETFLIX STATISTICS

Average: 13.00

Median: 12.00

Mode: there is no mode.

CSC1310: lab 7C++ standard template library vector class
$30.00 $24.00