help please

This is a discussion on help please within the C++ Programming forums, part of the General Programming Boards category; I have tried if statements but there are so many of them. eg if ((t1 > 0) && (t2 <= ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    2

    help please

    I have tried if statements but there are so many of them.
    eg

    if ((t1 > 0) && (t2 <= 600)
    user_rate = (600 - t1) * rate_1;
    else if (t1 >= 6) && (t2 <= 1200)
    user_rate = (1200 - t1) * rate_2;
    esle if (t1 >= 1200) && (t2 <= 1800);
    user_rate = (1800 - t1) * rate_3;
    else if (user_rate >= 1800) && (t1 <= 2400)
    user_rate = (2400 - t1) * rate_4;
    else if (t1 >= 1800) && (t1 <= 2400)
    user_rate = (2400 - t1) * rate_4;

    My problem is when the times overlap each other.

    what if the user starts at 1000 and finishes at 1400? etc

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Make an extra inclusion guards

    if (t1>0 && t1<6 && t2<=600)


    U will probably have four for most of them

Popular pages Recent additions subscribe to a feed

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