Syntax problem

This is a discussion on Syntax problem within the C++ Programming forums, part of the General Programming Boards category; I am a newbie to programming and I have a problem. I need to put this in the correct syntax. ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    15

    Talking Syntax problem

    I am a newbie to programming and I have a problem. I need to put this in the correct syntax.
    Daily bonus points are accrued at 300 points for every three days.
    Mileage bonus points are are accured at 250 points for every 300 miles driven.
    Bonus points are not prorated.
    Please help me put this into a correct syntax

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    show us what you have so far?

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    here im not sure exactly what you are needing,
    so ill post this, it needs alot of work, and will not
    work correctly unless the amounts are evenly divided.

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    	int days, miles;
    	cout << "how many days?" << endl;
    	cin >> days;
    	cout << "how many miles?" << endl;
    	cin >> miles;
    	cout <<"# of points : ";
    	cout << (days * 100) + ((miles/300) * 250) << endl;
    	cin.ignore( 100 , '\n' );
    	cin.get();
    	return 0;
    }
    Code:
    output : 1250 points
    with 10 days and 300 miles.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    15
    I need a math solution I guess. I want to be able to put in any number of miles driven and the number of rented and have it compute the bonus points.

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    number of days divided by 3 is the number of times you will multiply by 300 to get number of daily bonus points. This works because in C++ if you use division of integers by integers you get an integer, with any decimal portion ignored-- which correlates with the statement that proration of points will not be allowed.

    number of miles driven divided by 300 is the number of times you will muliply by 250 to get the number of miles bonus points.

    Total bonus points is the sum of the two types of bonus points.
    You're only born perfect.

  6. #6
    Banned
    Join Date
    Jun 2005
    Posts
    594
    nah no need to divide days by 3, just use 1 day = 100 points

    unless of course you dont get any points unless it
    been 3 days. then you will need to do that.

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    15
    You guys are great. My program is perfect. I did the calculations in the way you described above and it worked perfectly. Thank You So Much!!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Includes making me insane >.<
    By IceDane in forum C Programming
    Replies: 14
    Last Post: 04-14-2008, 10:24 AM
  2. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  3. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  4. syntax linked list problem & struct problem
    By beely in forum C Programming
    Replies: 5
    Last Post: 11-11-2002, 08:14 AM
  5. DJGPP assembly syntax ills...
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-11-2001, 01:54 AM

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