CSCI 261 - Programming Concepts (C++)Spring 2017 - Lab 04AQuick Links: Blackboard | Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks |
||||||||||||||||
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | ||||||||||||||||
This lab is due by
Tuesday, February 7, 2017 11:59pm.
Triangle Classifier + REPL
To gain practice with
while
loops, we will use a
while
loop to validate user input, and continue asking for input until a
valid input is given.
Creating a REPL (Read, Evaluate,
Print, Loop) is a way that we can repeatedly ask for a user's input and
provide immediate feedback. We're going to build a REPL for triangle
measurement input (because triangles are so cool, we just can't stop
talking about them).
InstructionsThis will be a new project. Create one
and call it Lab04A.
Recall in Lab 03B that a user enters three
triangle measurements. In Lab03B, we checked a triangle's feasibility
and set
isTriangle
to
false
if the measurements entered did not form a triangle. Wouldn't it be
more useful if we could force the user to input valid measurements;
that is, if we asked for input again if what was entered is invalid?
In a REPL program, you want to continually do the following:
In this assignment, you will ask the user to enter three real value
measurements for their triangle, and store them in some variables.
Then, continue to ask the user for their measurements until they are
valid (i.e., all measurements > 0 and measurements form a triangle).
Here is pseudocode for your Lab04A program:
When creating this sort of input loop, it's important that the user
understands what's taking place. If the user has entered invalid input,
notify them of it appropriately (e.g., input is <0). It's helpful to
put yourself in the user's shoes, and ask questions such as "If I were
using this program, how would I want it to work?"
Test Values
Here are some known input/output values that you can test against. Be sure to try your own to verify
the code works!
Lab Submission
You will submit your solution to this lab with the rest of Week04.
Detailed instructions for doing this are posted in Assignment 04.
This lab is due by
Tuesday, February 7, 2017 11:59pm.
| ||||||||||||||||
Last Updated: 01/01/70 00:00
|