CSC160 (UG20) 01
TPS 3: Input/output
Skip To Content
Dashboard
  • Login
  • Dashboard
  • Calendar
  • Inbox
  • Help
Close
  • My Dashboard
  • CSC160 (UG20) 01
  • Assignments
  • TPS 3: Input/output
SP 2021 (UNDG)
  • Home
  • Assignments
  • Modules
  • TC/WC Appt Scheduler
  • Collaborations
  • WSJ Context
  • EvaluationKIT Course
  • EvaluationKIT
  • Barnes & Noble Bookstore
  • Badges

TPS 3: Input/output

  • Due Feb 19, 2021 by 10am
  • Points 1
  • Submitting a file upload
  • File Types doc and docx
  • Available after Feb 19, 2021 at 9am

Consider this program:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Purpose: Asks the user for their favorite number and ice cream flavor.
#include <iostream>
using namespace std;

int main(){
    // Variable declarations
    string iceCreamFlavor;
    int number;

    // Prompt the user for their favorite number and ice cream flavor.
    cout << "Please enter your favorite number: ";
    cin >> number;

    cout << "Enter your favorite ice cream flavor: ";
    getline(cin, iceCreamFlavor);

    // Repeat their input.
    cout << "That's funny, " << number << " is my favorite number and "
         << iceCreamFlavor << " is my favorite flavor, too!" << endl;

    return 0;
}

After I compile it and then run it, it asks me for my favorite number and waits for me to enter it. I enter it, then the question asking for my favorite ice cream flavor appears, but it does wait for me to input anything, it just continues on to the output statement. Here's what it looks like (my input is in orange):

./ice-cream
Please enter your favorite number: 5
Enter your favorite ice cream flavor: That's funny, 5 is my favorite number and  is my favorite flavor, too!

1) What's going on and 2) how do I fix it?

 

After we've completed the group share portion, please upload a copy of your updated TPS document.

1613746800 02/19/2021 10:00am
Additional Comments:
Rating max score to > pts

Rubric

 
 
 
 
 
 
 
     
Can't change a rubric once you've started using it.  
Find a Rubric
Find Rubric
Title
You've already rated students with this rubric. Any major changes could affect their assessment results.
Title
Criteria Ratings Pts
Edit criterion description Delete criterion row
This criterion is linked to a Learning Outcome Description of criterion
threshold: 5 pts
Edit rating Delete rating
5 to >0 pts
Full Marks
blank
Edit rating Delete rating
0 to >0 pts
No Marks
blank_2
This area will be used by the assessor to leave comments related to this criterion.
pts
  / 5 pts
--
Additional Comments
Total Points: 5 out of 5