CSCI 261 - Programming Concepts (C++)

Spring 2017 - Lab 02B

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

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

You are encouraged to continue pair programming for this and all future labs. Reminder, if you do so, you must put both of your names in the header comments section of your main.cpp .


Roll the Die!



D20 Hug
For this lab, you will be simulating a die roll. Be sure to be seeding the random number generator (affectionately called the RNG) with time properly. Then ask the user how many sides the die they are using is (you can assume their input will be greater than zero and less than 1,000). You will then simulate five "dice rolls."

To do this, generate a random number with a value between 1 and the value entered by the user, inclusive (that means 1 and the user's number are included in the range). Print out to the user this value in a format similar to below:

How many sides does our die have? 32
The die has been cast to: 17

Now we can potentially have a 500-sided die being rolled. We want our numbers to be well-aligned, not like the following (red background is a visual cue for bad):

How many sides does our die have? 500
The die has been cast to: 17
The die has been cast to: 7
The die has been cast to: 170
The die has been cast to: 427
The die has been cast to: 51

Using proper IO manipulators, right align all of our dice values to match the following:

How many sides does our die have? 500
The die has been cast to:  21
The die has been cast to:   1
The die has been cast to: 333
The die has been cast to:   7
The die has been cast to: 251


Lab Submission



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


This lab is due by January 24, 2017 11:59PM.
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