CSCI 261 - Programming Concepts (C++)

Fall 2017 - Lab 5B

Quick Links: Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |
This lab is due by Tuesday, October 24, 2017 11:59 PM .

Instructions



This lab will make Lab4B 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 in order:
  1. How many numbers the user entered.
  2. The numbers the user entered in order.
  3. The smallest number they entered.
  4. The largest number they entered.
  5. The first number they entered.
  6. The last number they entered.
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 smallest number is: 2
The largest number is: 9
The first number is: 8
The last number is: 4
Gaze at my awesome.

A second interaction may look like:

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: -1
So awesome! You entered 4 numbers.
The numbers are: 8 6 7 9
Have a nice day!
The smallest number is: 6
The largest number is: 9
The first number is: 8
The last 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.
  • 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.
  • You must iterate through the vector again after printing all the values. You should not keep track of the smallest and largest value as the user is entering them.


Lab Submission



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


This lab is due by Tuesday, October 24, 2017 11:59 PM .
Last Updated: 10/10/17 20:34


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