Lab2: Interacting with users
Contents
Instructions
In this lab, you will write a program that interacts with a user. Don't worry, I'll give you much of what you need to complete it.
This program is going to act like it's intelligent, but it won't be. It will ask the user questions, and then provide statements that make it seem like it's understood what the user wrote, but those statements will be meaningless. Here's an example (my input is in this color):
******************************************************************************** WELCOME TO JOE'S CAFE ******************************************************************************** Cashier: Hello! What's your name? You: Hank Cashier: Welcome to Joe's Cafe, Hank. What would you like? A coffee or espresso? You: espresso Cashier: Good choice, I love espresso. Do you want that for here or to-go? You: to-go Cashier: Great, one espresso to-go, that will be $3. Would you like to donate to the Joe's Children Fund? How much would you like to give? You: 1.50 Cashier: Thanks, Hank, your total is $4.50 and your order will be right up.
You can use this example as your script, or you can do something similar. The important parts are, the program must:
- prompt the user at least four times
- everything the user enters should be repeated back some how
- at least one input should be a string and at least one number (can be a float or int)
- the number should be used in some sort of mathematical expression (e.g., in the example above, the amount to donate is added to the cost of the beverage)
Here is a C++ template to get you started. Copy and paste this into a Sublime Text editor and begin writing your code. You should use an incremental approach: implement one or two lines, then try compiling and test the program.
Submission
Submit .cpp file to here. You can view the rubric here.
(Back to top)