# Hot Peppers

## Problem Statement

• Write a C++ program that asks the user for a minimum “hotness” (in Scovilles). Report back the pepper closest (but greater than or equal) to their input.
• To get started, try thinking through some sample inputs
• Avoid duplicating code.

## Solution

/*
Test Case 1:
Input: -5 (negative example)
Output: red bell pepper
Actual: red bell pepper

Test Case 2:
Input: 0 (border case)
Output: red bell pepper
Actual: red bell pepper

Test Case 3:
Input: 2000000

Test Case 4:
Input: 2000001
Output: no pepper
Actual: no pepper
*/

#include <iostream>
#include <string>

using namespace std;

// You should use more descriptive var names than these...
const int RED_BELL_PEPPER = 0;
const int PIMENTO = 900;
const int JALAPENO = 8000;
const int SERRANO = 23000;
const int BIRDS_EYE = 100000;
const int SCOTCH = 350000;
const int BHUT = 1463700;
const int TRINIDAD = 2000000;

int main()
{
// inputs: hotness in scovilles
// outputs: which pepper to eat

/// Prompt
int desired_hotness;
cout << "What's the minimum hotness you wanna try? ";
cin >> desired_hotness;

string right_pepper = "";

// Find the right pepper
if (desired_hotness <= RED_BELL_PEPPER)
{
right_pepper = "Red Bell Pepper";
}
else if (desired_hotness <= PIMENTO)
{
right_pepper = "Pimento Chilli";
}
else if (desired_hotness <= JALAPENO)
{
right_pepper = "Jalapeno";
}
else if (desired_hotness <= SERRANO)
{
right_pepper = "Serrano";
}
else if (desired_hotness <= BIRDS_EYE)
{
right_pepper = "Bird's Eye Chilli";
}
else if (desired_hotness <= SCOTCH)
{
right_pepper = "Scotch Bonnet";
}
else if (desired_hotness <= BHUT)
{
right_pepper = "Bhut Jolokia";
}
else if (desired_hotness <= TRINIDAD)
{
right_pepper = "Trinidad Moruga Scorpion Chilli";
}
else
{
right_pepper = "No pepper known to man";
}

// Print out the right pepper
cout << "You should eat a " << right_pepper << endl;
system("pause");
return 0;
}
cs-142/hot-peppers.txt · Last modified: 2015/05/12 13:14 by cs142ta