IF Statements ?

This is a discussion on IF Statements ? within the C++ Programming forums, part of the General Programming Boards category; I am having a difficult time making it work, some expertise or hints. Retail Price = 99.00 and for each ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    2

    Question IF Statements ?

    I am having a difficult time making it work, some expertise or hints.


    Retail Price = 99.00 and for each units sold you get a discount. This program should calculate quantity discounts:

    Input Validation: units > 0






    #include <iostream>
    #include <iomanip>
    using namespace std;

    int main()
    {
    float units;
    float total;
    float discount;
    cons float price = 99.00

    cout << fixed << showpoint << setprecision (2);

    cout << "how many units sold?";
    cin >> units;

    if ( units >= 10 && units >= 19)
    discount = .20;

    else if ( units >= 20 && units <= 49)
    discount = .30;

    else if ( units >= 50 && units <= 99)
    discount = .40;

    else if ( units >= 100)
    discount = .50;

    total = (units * price ) - discount;

    cout << "The total sales: " << total << endl;

    return 0;
    }

    survivor::

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Code:
    units >= 10 && units >= 19
    shouldnt this be

    Code:
    units >= 10 && units <= 19

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    should be: const float price = 99.;

    what exactly is the problem, try RoD's fix; if that doesn't help, explain what you're expecting and what it doesn't do. is it not outputting the right amount? etc.etc. ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. newbie question - if statements without conditions
    By c_h in forum C++ Programming
    Replies: 2
    Last Post: 07-18-2008, 11:42 AM
  3. C++ If Statements Help
    By moporho in forum C++ Programming
    Replies: 19
    Last Post: 01-18-2008, 08:40 AM
  4. Efficiency of case statements
    By Yasir_Malik in forum C Programming
    Replies: 26
    Last Post: 05-23-2006, 12:36 PM
  5. Need help with "if" statements
    By Harryt123 in forum C Programming
    Replies: 22
    Last Post: 05-14-2006, 09:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21