BYU Health Insurance

Problem Statement

  • Write a program to determine a user’s monthly health insurance premium based on their marital status and the number of dependents.

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");
}
cs-142/byu-health-insurance.txt · Last modified: 2015/05/12 13:17 by cs142ta
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0