The new guy

How do I work this? Health Insurance Premium is $500.00 plus $100.00 per dependent. User tells you how many dependents, you tell what the premium will be.

Last edited on
Let x be the number of dependents. 100x + 500 is the equation. Tell the program how many dependents there are, multiply that by 100, and then add 500:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream>
#include<cmath>
int premium(int dependents);
int main(void)
{
using namespace std;
cout << "Enter number of dependents...\n";
int d;
cin >> dependents;
int answer = premium(d);
cout << answer;
return 0;
}
int premium(int dependents)
{
return (100 * dependents) + 500;
}

Last edited on
giving someone the code is not really teaching them or helping expand their programming knowledge...
Topic archived. No new replies allowed.