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

TPS 9: Functions II

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

Here's the program we started working on at the end of last class. We filled in the second two parameter in the FindMinMax function definition on line 19. Fill in as many of the remaining blanks as possible.

 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//==============================================================================
// File:    lecture6-normalize.cpp
// Author:  CSC160 class
// Date:    29-Mar-2021
// Purpose: Reads a list of real numbers from the user and scales them using
//          min-max normalizations.
//==============================================================================
#include <iostream>
#include <vector>
using namespace std;

/**
 * Finds the min and max values in the given vector.
 * 
 * @param numbers A list of real numbers.
 * @param min A variable to hold the min value from numbers in (gets updated).
 * @param max A variable to hold the max value from numbers in (gets updated).
 */
void FindMinMax(vector<double> numbers, double &min, double &max){
    if(numbers.size() > 0){
        min = numbers.at(0);
        max = numbers.at(0);
    }

    // Find the min and max values in the vector.
    for(unsigned int i = 0; i < numbers.size(); i++){
        if(_______ < min){
            min = numbers.at(i);
        }
        ____(numbers.at(i) > max){
            max = numbers.at(i);
        }
    }
}


/**
 * Scales each of the values in the given vector so that it is between 0 and 1.
 * Uses min-max normalization for scaling.
 * 
 * @param numbers A list of real numbers to scale (gets updated)
 */
void Scale(____________){
    double min, max;
    // Find the min and max.
    _________(numbers, min, max);

    // Scale.
    for(unsigned int i = 0; i < numbers.size(); i++){
        _________ = (numbers.at(i)-min)/(max-min);
    }
}

/**
 * Reads a list of real numbers from the user and scales them using min-max 
 * normalizations.
 * 
 * @return The program's exit status (0 is good).
 */
int main(){
    vector<double> numbers;
    double number;

    cout << "Enter as many floating point numbers as you'd like; "
         << "enter STOP to stop:" << endl;

    // Read in all of the doubles until there's an error reading a value in
    // (we'll use that error as the implicit sentinel value).
    cin >> number;
    while(cin.good()){
        numbers.push_back(number);
        cin >> number;
    }

    // Scale the values.
    ____________;

    // Print.
    for(unsigned int i = 0; i < numbers.size(); i++){
        cout << numbers.at(i);

        // Only print a comma if this isn't the last number in the vector.
        if(i < __________){
            cout << ", ";
        } 
    }
    cout << endl;

    return 0;
}

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

1617199200 03/31/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