output stuck in option 3?

Hi, I'm writing a program that's just about finished, but I can't seem to get the right output. There are 5 possible choices, and I wrote then out in an if, else fashion, expecting the final result to get presented if all preceding conditions aren't met. Here is the code

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iostream>
#include <string>
using namespace std;

int main()
{
	cout << "Company name: ";
	string companyName;
	getline(cin, companyName);
	cout << endl;

	cout << "Annual sales (in trillions): ";
	double annualSales;
	cin >> annualSales;
	cin.ignore(100, '\n');
	cout << endl;


	cout << "Industry: ";
	string industry;
	getline(cin, industry);
	cout << endl;

	string mud;
	string phishing; //make sure to go back and include while stmt.




	cout << "Number of employees: ";
	int employees;
	cin >> employees;


	cout << "___";

	cout << endl;

	double grandTotal;

	// Equations-------------------------------------------------------------------

	if (annualSales <= 500)
	{
		grandTotal = (annualSales * .20);

	}

	if ((annualSales > 500) & (annualSales < 900))
	{
		grandTotal = (((annualSales - 500) * .10) + 100); // if atleast 500 trillion

	}

	if ((annualSales <= 500) && (industry = mud) || (industry=phishing));
	{
		grandTotal = (((annualSales - 500)* .15) + 100); // mud or phishing

	}

	if (annualSales <= 500) & (industry = phishing);
	{grandTotal = (((annualSales - 500)* .15) + 100); }

	if (annualSales >= 700)
	{
		grandTotal = (employees * 0.01); //employee bonus
	}



	

	// results----------------------------------------------------------------------

	if (companyName == "")
	{
		cout << "You must enter a company name. "; cout << endl; return 0;
	}

	else if (annualSales < 0)
	{
		cout << "The annual sales must be nonnegative."; return 0;
	}

	else if (industry == "")
	{
		cout << "You must enter an industry. "; cout << endl;
	}

	else if (employees < 0)
	{
		cout << "The number of employees must be positive"; cout << endl;
	}

	else cout << companyName << " can borrow up to G" << grandTotal << " trillion. "; cout << endl;
}


THe results// part is where i'm struggling. All help is very much appreciated. I don't expect anyone to fix it, but tips and suggestions are very useful. Thanks!
what output are you getting?

if ((annualSales > 500) & (annualSales < 900))

Bitwise operator?

1
2
3
4
5
6
7
8
9
if ((annualSales <= 500) && (industry = mud) || (industry=phishing)); // <-- semi colon?
	{
		grandTotal = (((annualSales - 500)* .15) + 100); // mud or phishing

	}

	if (annualSales <= 500) & (industry = phishing); // <-- semi colon? and bitwise operator?

	{grandTotal = (((annualSales - 500)* .15) + 100); }


Last edited on
hello, I keep getting: "You must enter an industry".

WHat is a bitwise operator?
sorry, I just started learning this stuff and haven't had much time to get into details because of work so I'm going off the bit that I know. Thanks for the help again.

for the part you quoted: *fixed

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
if (annualSales <= 500)
	{
		grandTotal = (annualSales * .20);

	}

	if ((annualSales > 500) & (annualSales < 900))
	{
		grandTotal = (((annualSales - 500) * .10) + 100); // if atleast 500 trillion

	}

	if (annualSales <= 500) & (industry = mud);
	{
		grandTotal = (((annualSales - 500)* .15) + 100); // mud or phishing

	}

	if (annualSales <= 500) & (industry = phishing);
	{grandTotal = (((annualSales - 500)* .15) + 100); }

	if (annualSales >= 700)
	{
		grandTotal = (employees * 0.01); //employee bonus
	}
campos10 wrote:
WHat is a bitwise operator?


A single ampersand & is the bit-wise and operator. You want the logical and operator which consists of two ampersands &&.

In the same vein, a single equal sign = is used for assignment. A double equal sign == is used for comparison. Is assignment what you meant to use in the expressions industry = mud and industry = phishing?

http://en.wikipedia.org/wiki/Bitwise_operation
Last edited on
AHHHHHHHHHH YESSSSS THAT WAS IT. I don't know how I missed that, thank you so much!
You are welcome. Please mark thread as solved so helpers know if there is an ongoing problem.
Topic archived. No new replies allowed.