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

    TPS 4: Branching

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

    Recall the program we wrote that asks the user for LaTeX: m , LaTeX: x , and LaTeX: b and then solves for LaTeX: y  in the equation LaTeX: y = mx+b :

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    // Purpose: Solves for y in y=mx*b.
    #include <iostream>
    using namespace std;
    
    int main(){
        float m, x, b, y;
    
        // Get the user's input.
        cout << "Please enter m, x, and b (separated by spaces): ";
        cin >> m >> x >> b;
    
        // Solve for y.
        y = m * x + b;
    
        // Output result.
        cout << "y = " << y << endl;
    
        return 0;
    }
    

    Suppose we want to allow the user to select to solve for y or LaTeX: x . If they want to solve for LaTeX: y , we ask for values for LaTeX: m , LaTeX: x , and LaTeX: b. If they want to solve for LaTeX: x , however, we will ask for the value of LaTeX: m , LaTeX: y , and LaTeX: b. Here is the mostly completed revised program:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    // Purpose: Solves for x or y in y=mx*b.
    #include <iostream>
    using namespace std;
    
    int main(){
        char varToSolveFor;
        float m, x, b, y;
    
        // Find out what the user wants to solve for.
        cout << "Which would you like to solve for, [x] or [y]? ";
        cin >> varToSolveFor;
    
        // Solve for y.
        if(_____________){
            // Get the user's input.
            cout << "Please enter m, x, and b (separated by spaces): ";
            cin >> m >> x >> b;
    
            // Solve for y.
            y = m * x + b;
    
            // Output result.
            cout << "y = " << y << endl;
        
        // Solve for x.
        } else if(_____________){
            // Get the user's input.
            cout << "Please enter m, y, and b (separated by spaces): ";
            cin >> m >> y >> b;
    
            // Solve for x.
            x = (y-b)/m;
    
            // Output result.
            cout << "x = " << x << endl;
    
        // Invalid input.
        } else {
            cout << "Invalid option." << endl;
        }
    
        return 0;
    }
    

    Specify what goes in the blanks on lines 14 and 26.

     

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

    1614178800 02/24/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