please run this simple program......
why wont this work ?
i tried it first with if...else
/*why will this program not run? what did i do wrong with the if else statements/conditions ?*/
#include <conio.h>
#include <iostream.h>
main()
{
double sales, sales_amount, quantity, total_sales, vat;
total_sales = sales + vat;
vat = 0.175*sales;
cout << "\nTotal Sales = sales amount * quantity\n"; endl;
cout << "\nEnter the sales amount\n";
cin >> sales_amount;
cout << "\nEnter the quantity\n" ;
cin >> quantity ;
sales = (sales_amount * quantity);
cout << "\n" << sales_amount << " * " << quantity << " = " << sales << "\n";
cout << "\n" << "Sales is: \t" << sales << "\n";
cout << "\ntotal sales inc VAT is: \t" << (sales + 0.175*sales) << "\n";
if (sales < 25) cout << "\nNo commission"; //<-------------why will this not run?
else if (50 > sales < 25) cout << "\n 5% commission " << total_sales * 0.05;
else if (75>sales<51) cout << "\n 10% commission "; << total_sales * 0.10;
else if (100>sales<76)cout << "\n 20% commission"; << total_sales * 0.20;
else cout << "20% commission" ;
getch();
}
i tried it with a switch statement
#include <conio.h>
#include <iostream.h>
main()
{
double sales, sales_amount, quantity, total_sales, vat;
total_sales = sales + vat;
vat = 0.175*sales;
cout << "\nTotal Sales = sales amount * quantity\n"; endl;
cout << "\nEnter the sales amount\n";
cin >> sales_amount;
cout << "\nEnter the quantity\n" ;
cin >> quantity ;
sales = (sales_amount * quantity);
cout << "\n" << sales_amount << " * " << quantity << " = " << sales << "\n";
cout << "\n" << "Sales is: \t" << sales << "\n";
cout << "\ntotal sales inc VAT is: \t" << (sales + 0.175*sales) << "\n";
switch(sales) {
case <25:
cout << "\nNo commission";
break;
case 50 > sales < 25:
cout << "\n 5% commission " << total_sales * 0.05;
break;
case 75 > sales < 51:
cout << "\n 10% commission "; << total_sales * 0.10;
case 100 > sales < 76:
cout << "\n 20% commission"; << total_sales * 0.20;
default:
cout << "\n 20% commission";
}
getch();
}
someone help me out please...