Table of Contents

BYU Health Insurance

Problem Statement

Values taken from http://www.dmba.com/nsc/handbooks/student/hbbyuldsbc2014.pdf#page=15

Solution

/*
Test Case 1:
Input: single, 0 dependents
Output: 74
Actual: 74
 
Test Case 2:
Input: single, 2 dependents
Output: 273.50
Actual: 273.50
 
Test Case 3:
Input: married, 0 dependents
Output: 118.50
Actual: 118.50
 
Test Case 4:
Input: married, 2 dependents
Output: 413.50
Actual: 413.50
*/
 
#include <iostream>
#include <string>
 
using namespace std;
 
const string TRUE = "Y";
 
int main()
{
	// INPUTS: whether single or married, dependents or no dependents
	// OUTPUT: premium
 
	string is_single = "Y";
	string has_dependents = "N";
 
	// Prompt user
	cout << "Are you single? (Y/N)";
	cin >> is_single;
 
	cout << "Do you have dependents? (Y/N)";
	cin >> has_dependents;
 
	double premium = 0.0;
 
	// Decide which premium they should pay
	if (is_single == TRUE)
	{
		if (has_dependents == TRUE)
		{
			premium = 273.5;
		}
		else
		{
			premium = 74;
		}
	}
	else
	{
		if (has_dependents == TRUE)
		{
			premium = 413.5;
		}
		else
		{
			premium = 118.5;
		}
	}
 
	cout << "premium: " << premium << endl;
 
	system("pause");
}