If Then statements.

Im trying to do a challange problem in my C++ text book. I have to allow the user to input a quantity and if they are in range for 5 different areas apply a discount to any given part.. Well im getting a "expected ; before else" error with my compiler. Here is my code,

#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;

int main()
{

double sale, discount, total, menu;
int pack; // to hold menu options

const double d1 = .2,
d2 = .3,
d3 = .4,
d4 = .5;
const int
Norm = 1,
Package = 2,
Quit = 3;



do {


cout << " Do you qualify for one of our discounts?" << endl;
cout << " Select the option below that coorisponds with your choice" <<endl;
cout << "----------------------------------------------------\n";
cout << endl;


cout << " 1. Total cost of your purchase with the discount " << endl;
cout << " 2. Quit the program. " << endl;
cout << "Enter your Choice: ";
cin >> menu;

if ((menu < 1) || (menu > 2 ));
{
cout << endl;
cout << "The valid choices are 1 through 2. Rerun the program\n";
cout << "again and select a valid choice.\n" << endl;
system ("pause");
system("CLS");
}
}while ((menu < 1) || (menu > 2 ));

system("CLS");

//set output formatting
cout << fixed << noshowpoint << setprecision(2) << endl;

//Calculate

cout << " Enter the amount of packages purchased " << endl;
cin >> pack;

if ( pack >= 10 ) // amount of discount based on purchase quantity
{
cout << " To qualify for a discount you must purchase 10 packages or more " << endl;
}

{
else (( pack == 11 ) || ( pack =< 20 ))

sale = pack * 99;
discount = sale * .02;
total = sale - discount;

cout << " You qualify for a 20% discount! " << endl;
cout << " Your purchase originally came to " << sale <<
" with a discount of " << discount << " Your price is " << total;
}
else (( pack == 20 ) || ( pack =< 50 ))
{
sale = pack * 99;
discount = sale * .03;
total = sale - discount;

cout << " You qualify for a 30% discount! " << endl;
cout << " Your purchase originally came to " << sale <<
" with a discount of " << discount << " Your price is " << total;
}
{ else (( pack == 50 ) || ( pack =< 100 ))

sale = pack * 99;
discount = sale * .04;
total = sale - discount;

cout << " You qualify for a 40% discount! " << endl;
cout << " Your purchase originally came to " << sale <<
" with a discount of " << discount << " Your price is " << total;

}
else ( pack >= 100 )
{
sale = pack * 99;
discount = sale * .05;
total = sale - discount;

cout << " You qualify for a 50% discount! " << endl;
cout << " Your purchase originally came to " << sale <<
" with a discount of " << discount << " Your price is " << total;
}
}
}
}


return 0;
} //end of main

Any help would be greatly appreciated
1
2
3
4
5
6
7
8
9
10
11
if ( pack >= 10 ) // amount of discount based on purchase quantity
{
cout << " To qualify for a discount you must purchase 10 packages or more " << endl;
}

{
else if (( pack == 11 ) || ( pack <= 20 ))
{
sale = pack * 99;
discount = sale * .04;
total = sale - discount;

Add if to other else's and change comparsion operator
Last edited on
Topic archived. No new replies allowed.