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
#include <iostream>
#include <string>
usingnamespace 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;
}
elseif (annualSales < 0)
{
cout << "The annual sales must be nonnegative."; return 0;
}
elseif (industry == "")
{
cout << "You must enter an industry. "; cout << endl;
}
elseif (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!
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.
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?