Run time Check Failure: The variable being used is not initialized

I'm not sure why I'm still getting this error I thought I initialized fourteenPercent correctly but when I run the program it comes up with a run time check failure error.

Here is the program summary of what I'm trying to make: A new author is in the process of negotiating a contract for a new romance novel. The publisher is offering three options. In the first option, the author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published. In the second option, the author is paid 12.5% of the net price of the novel for each copy of the novel sold. In the third option, the author is paid 10% of the net price for the first 4000 copies sold, and 14% of the number of copies that will be sold and would like to have an estimate of the royalties generated under each option. Write a program that prompts the author to enter the net price of each copy of the novel and the estimated number of copies that will be sold. The program then outputs the royalties under each option and the best option the author could choose.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double option1, option2, option3, copiesSold, priceperCopy, tenPercent, fourteenPercent;
	double finalManu, published;
	
	cout<<"Enter price of each copy: ";
	cin>>priceperCopy;
	cout<<"Estimated number of copies sold: ";
	cin>>copiesSold;

	finalManu = 5000, published = 20000;

	
	if (copiesSold <= 4000)
		tenPercent = (priceperCopy * copiesSold) * 0.1;
	
	if (copiesSold > 4000)
		fourteenPercent = ((priceperCopy * copiesSold) - 4000) * 0.14;

	option1 = finalManu + published;
	option2 = (priceperCopy * copiesSold) * 0.125;
	option3 = tenPercent + fourteenPercent;


	cout<<"Royalties under option 1: $"<<finalManu<<" upon delivery of final transcript and "<<endl;
	cout<<"$"<<published<<" when novel is published so total is $"<<option1<<endl;
	cout<<endl;
	cout<<"Royalties under option 2: $"<<option2<<" total paid for "<<endl; 
	cout<<"\n 12.5% of the net price of the novel for \n"<<copiesSold<<"\n copies sold. \n"<<endl;
	cout<<endl;
	cout<<"Royalties under option 3: $"<<option3<<" total paid for "<<copiesSold<<" copies sold."<<endl;
	cout<<endl;

	if(option1 > option2 && option1 > option3)
		cout<<"Option 1 is the best option you can choose for maximum royalties.";
	if(option2 > option1 && option2 > option3)
		cout<<"Option 2 is the best option you can choose for maximum royalties.";
	if(option3 > option1 && option3 > option2)
		cout<<"Option 3 is the best option you can choose for maximum royalties.";

	return 0;

}
If copiesSold is 4000 or less, tenPercent will be initialized but fourteenPercent will not.

If copiesSold is more than 4000, then fourteenPercent will be initialized but tenPercent will not.
Topic archived. No new replies allowed.