CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: calculating discount percents

    Try typing these lines into the beginning of your program and see what happens:
    Code:
    for (int i = 0; i < 10; i++)
        cout << i/4 << endl;
    for (int i = 0; i < 10; i++)
        cout << i/4.0 << endl;

  2. #17
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: calculating discount percents

    rottenstock, have you noticed that the layout when you post code differs from when others post code? That's because posts in this forum uses some formatting tags. You can read more about them here http://www.codeguru.com/forum/misc.php?do=bbcode
    Last edited by S_M_A; May 8th, 2009 at 03:22 PM. Reason: Spelling
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #18
    Join Date
    Nov 2010
    Posts
    1

    Re: calculating discount percents

    everytime i do it how i think it should be done, the result is 0.

    I'm very new at this, but from the research i have done, it seems like i should use a float command, but i am still confused by that.

    Basically, it's going to be:

    ItemPrice * ProductDiscountRate (which should be a %, like .25) = Subtoal

    and then the Senior Discount is suppose to be Subtotal * SeniorDiscountRate

    But both of those ways return a value of 0.


    Government ********

  4. #19
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: calculating discount percents

    Quote Originally Posted by christinejones View Post
    everytime i do it how i think it should be done, the result is 0.

    I'm very new at this, but from the research i have done, it seems like i should use a float command, but i am still confused by that.

    Basically, it's going to be:

    ItemPrice * ProductDiscountRate (which should be a %, like .25) = Subtoal

    and then the Senior Discount is suppose to be Subtotal * SeniorDiscountRate

    But both of those ways return a value of 0.


    ********** ********
    You're allowed to start your own thread.

    Let's see your code.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured