CSCI 261 - Programming Concepts (C++)

Fall 2016 - Lab 08A

Quick Links: Blackboard | EECS | Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |
This lab is due by November 02, 2016 08:00am.


Instructions



This lab will make Lab07B more flexible. Instead of requiring the user to enter 15 numbers every time, we will allow the user to enter as many numbers as they wish (assume they will enter at least 1 number). The user will enter non-negative numbers (greater than or equal to zero) one at a time. When the user wishes to no longer enter numbers, the user should enter -1 to signal they are done.

When the user is done entering numbers, print how many numbers the user entered. Then print out the numbers the user entered.

After printing out the values the user entered, modify your function to accept a vector. Name this new function FindLargestVectorValue and then call your function and print the resulting largest value.

An example interaction follows:

Hey! Witness my first vector mojo!
Enter as many non-negative numbers as you'd like and I will tell you what they are. When you wish to be done, enter -1 to stop entering numbers.
Your Number Is: 8
Your Number Is: 6
Your Number Is: 7
Your Number Is: 9
Your Number Is: 3
Your Number Is: 2
Your Number Is: 4
Your Number Is: -1
So awesome! You entered 7 numbers.
The numbers are: 8 6 7 9 3 2 4
Have a nice day!
The largest number is: 9
Gaze at my awesome.


Functional Requirements



  • Your function cannot make a call to the STL Algorithm method sort(). You must iterate through the vector searching for the largest element yourself.
  • Additionally, your function should not modify the contents of the vector. That is to say, when the function is complete the vector will have the same value as it did when it was passed into the funciton. Maybe we should have our vector parameter be constant to ensure it doesn't change.
  • When printing the number of numbers entered by the user, do not use a counter inside the loop. Instead, make use of one of our vector functions to determine this value.


Lab Submission



You will submit your solution to this lab with the rest of Week09. Detailed instructions for doing this are posted in Assignment 09.


This lab is due by November 02, 2016 08:00am.
Last Updated: 01/01/70 00:00


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0