Please send questions to
st10@humboldt.edu .
/*-----
Contract: main: void -> int
Purpose: ask the user for Scoville ratings and give
him/her the minimum recommended audience for
each, printed to the screen,
until he/she enters a negative rating
to say he/she is ready to quit -- and then
it prints to the screen the number of
ratings given by the user, and the highest
of Scoville rating given
Examples: if, when I run this program, I enter:
250, 750, 1250, 500, 1000, -2 when prompted, the following
would be printed to the screen:
the minimum rec'd level is: infant
the minimum rec'd level is: toddler
the minimum rec'd level is: adult
the minimum rec'd level is: toddler
the minimum rec'd level is: adult
Number of Scoville ratings given: 5
Highest Scoville rating given: 1250
Number at the toddler level: 2
----------------
if, when I run this program, I enter:
-3 when prompted, the following should be printed
to the screen:
Number of Scoville ratings given: 0
Highest Scoville rating given: not applicable
Number at the toddler level: 0
by: Sharon Tuttle
last modified: 4-14-10
-----*/
#include <iostream>
#include "spiciness_level.h"
using namespace std;
int main()
{
int sco_rating;
string sco_level;
int max_rating_so_far = -1; // so it MUST be reset -- there are
// no negative Scoville ratings
int num_ratings = 0;
int num_toddler = 0;
// get the first Scoville rating
cout << "Enter a Scoville rating (or a negative number to quit): ";
cin >> sco_rating;
// handle all actual Scoville ratings
while (sco_rating >= 0)
{
// handle this rating
sco_level = spiciness_level(sco_rating);
cout << "the minimum rec'd level is: "
<< sco_level << endl;
num_ratings++;
if (sco_level == "toddler")
{
num_toddler++;
}
if (sco_rating > max_rating_so_far)
{
max_rating_so_far = sco_rating;
}
// get the next rating
cout << "Enter a Scoville rating (or a negative number to quit): ";
cin >> sco_rating;
}
cout << "Number of Scoville ratings given: " << num_ratings
<< endl;
cout << "Highest Scoville rating given: ";
if (num_ratings == 0)
{
cout << "not applicable" << endl;
}
else
{
cout << max_rating_so_far << endl;
}
cout << "Number at the toddler level: "
<< num_toddler << endl;
return EXIT_SUCCESS;
}