concrete discounts determined by the amount bought

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scladycat22
    New Member
    • Nov 2013
    • 2

    concrete discounts determined by the amount bought

    I am trying to calculate a discount based on amount bought. Can someone tell me why this doesn't work?
    Code:
    if (concreteAmount<=500)
         concreteDiscount=.02;
    	else if (concreteAmount>500 && concreteAmount<9001)
    	concreteDiscount=.04;
    	else if (concreteAmount>9000 && concreteAmount<15001)
    	concreteDiscount=.05;
    	else if (concreteAmount>15000)
    	concreteDiscount=.09;
    	else concreteAmount<0;
    	cout<< "Error, please try again."
    Last edited by Rabbit; Nov 12 '13, 04:42 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • scladycat22
    New Member
    • Nov 2013
    • 2

    #2
    do I need to post more of the code?

    Comment

    • divideby0
      New Member
      • May 2012
      • 131

      #3
      With your code, the last else path wouldn't be reached since any valid input less than or equal to 500 will take the first if path.

      If it isn't a typo, the last else is syntactically incorrect as well. You wouldn't want the concreateAmount < 0;

      HTH

      Comment

      Working...