I need help

I am writing a program for class and have no clue what I am really doing. We are talking about loops and I am assuming I need to use a loop in the program. I can get it to work as an if else program but am having trouble getting the code to not accept a negative number. any advise would be great.
here is my code
#include <iostream>
using namespace std;
int main()
{
int item, total, order;
double discount, dis;

cout << "Enter the quantity for your order ";
cin >> order;
if( order<5)
(discount = 0.0);
else if ( order >=5 && order <= 10)
(discount = .10);
else if( order > 10 && order<=20)
(discount = .15);
else if( order > 20 && order <=30)
(discount = .20);
else if( order >30)
(discount = .25);

item = 12;
dis = item-(item*discount);
cout<< "The cost per shirt is "<<dis <<".\n";
total = (item-(item *discount))*order;
cout << "Your total price is " <<total<<".\n";
system("pause");
return 0;
}
For the negative number problem you can add another else if ike this

1
2
else if(order<1)
    cout<<"Order is not Valid!"
Please use the code tag and indentation.
Could be like this:
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
#include <iostream>

int main()
{
	std::cout << "Enter the quantity for your order ";
	int order = 0;
	std::cin >> order;
	if (order > 0)
	{
		double discount = 0.0;
		if (order < 5)
		{
			discount = 0.0;
		}
		else if (order <= 10)
		{
			discount = 0.10;
		}
		else if (order <= 20)
		{
			discount = 0.15;
		}
		else if (order <= 30)
		{
			discount = 0.20;
		}
		else
		{
			discount = 0.25;
		}

		int item = 12;
		double dis = item - (item * discount);
		std::cout << "The cost per shirt is " << dis << ".\n";
		double total = dis * order;
		std::cout << "Your total price is " << total << ".\n";
	}
	else
	{
		std::cout << "Invalid quantity.\n";
	}
	system("pause");
	return 0;
}
Topic archived. No new replies allowed.