Black Box Testing A customer has requested a program be developed to meet the fo
ID: 3627608 • Letter: B
Question
Black Box Testing
A customer has requested a program be developed to meet the following criterion:
1. The program needs to convert from Celsius temperatures to Fahrenheit temperatures.
2. The user should be able to enter temperatures containing fractional degrees (ie. 12.3)
3. The converted temperatures should be accurate to within 1/10th of a degree.
4. The user should be able to enter the number of temperatures to be converted up to a maximum of 10.
5. The output should be tabular with each row including the input and converted temperature.
Write a test plan to thoroughly test this program. The executable for this program is included in with this lab. You should have test cases which verify that the program does all of what is required in the problem specification above. You should also test to see how robust the program is, that is, how it handles inputs outside the expected ranges.
Document your test plan in a table. For each test case, document the expected program behavior and the actual program behavior. If the program does not behave according to your prediction, write a brief explanation of what the program did wrong.
write a test plan, documenting each test case including predicted and actual results along with explanations.
Explanation / Answer
#include <iostream>
#include <cstdlib>
using namespace std;
//Named Constants:
const size_t MAX_TEMPS = 10; // maximum number of temperatures to convert
//Prototypes:
//[°F] = [°C] × 9/5 + 32
// converts a given temperature in celsius to fahrenheit
double c_to_f(double degrees);
// converts the temperatures in the array, displaying the original and the
// new value
void convert_temps(double a[], size_t number_used);
// fills a array with a user indicated number of temperatures
void fill_array(double a[], size_t& number_used);
//Function definitions:
//-------------------------------------------------------------------------
int main( )
{
double temperature[MAX_TEMPS];
size_t number_used;
fill_array(temperature, number_used);
convert_temps(temperature, number_used);
return 0;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
double c_to_f(double degrees)
{
return degrees * (9.0/5) + 32;
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
void convert_temps(double a[], size_t number_used)
{
size_t i;
for(i=0; i < number_used; ++i)
{
cout << a[i] << " " << c_to_f(a[i]) << endl;
}
}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
void fill_array(double a[], size_t& number_used)
{
double next;
size_t i;
cout << "Enter up to " << MAX_TEMPS << " temperatures." << endl;
cout << "How many temperatures do you wish to convert?" << endl;
cin >> number_used;
cout << "Enter " << number_used << " temperatures" << endl;
for(i = 0; i < number_used; ++i)
{
cin >> next;
a[i] = next;
}
}
//-------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.