need help with discount code??

i am supposed to create a code that a user can input the number of an item and will get the total. the number of items ordered determines the pricing they will get. 1 item $10, 2-4 items $9ea., 5-9 items $8ea., 10+ items $6ea. this is what i have thus far. please help i am not good at programming. i am using DEV C++


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{

int choice = 0;
double number,
number2,
number3,
discount,
discount2,
discount3;

cout << "Enter the number of products you would like to determine your rate: ";
cin >> choice;

if (choice == 1)
{
cout << "The price for one is $10 ";

}

if (choice > 2 || choice < 4);
{
cout << "\n\nEnter the number of widgets: ";
cin >> number;

discount = (number * 9) ;
cout << "\n\nThe total is " << discount;
}

if (choice > 5 || choice < 9)
{
cout << "\n\nEnter the number of widgets: ";
cin >> number2;

discount2 = (number2 * 8) ;
cout << "The total is " << discount2;
}

if (choice > 10)
{
cout << "\n\nEnter the number of widgets: ";
cin >> number2;

discount3 = (number3 * 6 ) ;
cout << "The total is " << discount3;
}

system("PAUSE");
return 0;
}
Firstly, rather than '>' you need '>='. in other words 'greater or equal to', otherwise you wont pass into your desired conditions. Similarly for '<'
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
#include <iostream>
using namespace std;


int main()
{

	int choice;
	float rate;
	float total;

	cout << "Enter the number of products you require: ";
	cin >> choice;

	if (choice == 1) 
		rate = 10.0;
	else if (choice >= 2 && choice <= 4)
		rate = 9.0;
	else if (choice >= 5 && choice <= 9)
		rate = 8.0;
	else
		rate = 6.0;   // anything 10 or over

	total = choice * rate;

	cout << "Quanitiy ordered: " << choice << " at a rate of $" << rate << " per item totalling $" << total;

	return 0;
}
i get an error when i change to >= or =<

i got the same error when trying to run the code you provided

errors:
multiple definition of 'main'
first defined here
id returned 1 exit status

Sounds like you have copied my full example code inside your main function resulting in duplicate main() 's

just copy and paste what's inside the { } of the main function into yours and everything will work, and for the record this code works fine as any code I provide is always written in and tested in Visual Studio 2013
i am not doubting your skill by any means i am just trying to figure out my errors. i am trying again
after doing as you said it works perfectly! you are a life saver thank you very much!!

Your welcome :)

i am not doubting your skill by any means i am just trying to figure out my errors. i am trying again


Sorry that's not how I intended it to look like, i was merely letting you know I write it and test it before posting so that it doesn't contain errors.

Glad you got sorted and working though :)

Take care.

Topic archived. No new replies allowed.