if ladder

I am trying to initialize a variable "amount" for the following conditions:

For the first 500 trillion grubnicks in sales, the company will be extended 20% of the amount of those sales in credit.
In addition, for the next 400 trillion grubnicks in sales (beyond the initial 500 trillion), the company will be extended additional credit equal to 10% of those additional sales. However, if the company's industy is phishing or mud (so spelled, entirely in lower case), the amount of this additional credit is 15% of those additional sales instead of 10%.
In addition, further credit will be extended in the amount of 3% of sales above 900 trillion grubnicks.
If a company's annual sales are at least 700 trillion grubnicks, then the credit line is further increased by 0.01 trillion grubnicks for every employee.

I already have variables for employees, industry and sales but I am struggling to initialize this variable because of the second condition. This is what I have so far:

1
2
3
4
5
6
7
8
double amount;
cout.setf (ios::fixed);
cout.setf (ios::showpoint);
cout.precision (2);

if (sales <= 500)
   amount == 0.20 * sales
else if


You should complete that else if statement. Hint: it involves the number 900 trillion and is similar to the first if statement.
I don't understand how to make it calculate 20% for the first 500 and then 10% for any value <= 400 that comes after that 500 if it's anything but phishing and mud and 15% for phishing and mud?
Any value that "comes after" 500 is just a value greater than 500. So, 501 "comes after" 500.
I'm not sure I follow where you're going with that explanation?
Here's a good starter:
6
7
8
9
10
11
12
13
if(sales <= 500)
{
    amount == 0.20 * sales;
}
else if(sales <= 900)
{
    amount = 0.20*500 + 0.10*(sales-500);
}
Last edited on
Topic archived. No new replies allowed.