Thread: Please Help Me with this beginner C++ Program!

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    Question Please Help Me with this beginner C++ Program!

    Ok, I need help with this, Im just starting out and have no clue where to start...this is what I have to do....

    Write a program to ask the user for odometer readings before and after and gallons of gas used for each of three trips. Calculate the distance and miles per gallon for each trip. Display that information in a report like:

    Trip Report
    Trip Start End Distance Gallons MPG
    1 10078.9 10172.6 93.7 4.65 20.0
    2 10364.0 10687.5 323.5 14.90 21.7
    3 11538.3 11647.8 109.5 5.34 20.5

    Could someone please show me where I start? I have no clue how, as stated im a beginner.

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    12
    Quote Originally Posted by ClearSights View Post
    Ok, I need help with this, Im just starting out and have no clue where to start...this is what I have to do....

    Write a program to ask the user for odometer readings before and after and gallons of gas used for each of three trips. Calculate the distance and miles per gallon for each trip. Display that information in a report like:

    Trip Report
    Trip Start End Distance Gallons MPG
    1 10078.9 10172.6 93.7 4.65 20.0
    2 10364.0 10687.5 323.5 14.90 21.7
    3 11538.3 11647.8 109.5 5.34 20.5

    Could someone please show me where I start? I have no clue how, as stated im a beginner.
    Simple, do TripStart Minus TripEnd millage as a values to get distances

    For Miles per gallon it's Miles/Gallons = MPG

    Setting up the displace will just be cleaver cout codes

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    everyone says simple but I am Very new too this....all I know how to do is little things....like cout, setw, fin, fout, endl, and other small functions

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    12
    Then you got everything you need.. Read it in english

    You need 3 start odometer readings right?
    Code:
    float odostart1,odostart2,odostart3;// for the 3 start distances
    So now you need end distances?
    Code:
    float odoend1,odoend2,odoend3;// for the 3 end distances
    Then it's just a continuation of the same math problem,
    odostart-odoend = distance

    and miles/gallons = MPG


    The only problem I have is what are you Inputs?

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    I didnt get any other information then what I stated....

    So I would start it kind of like this?....

    #include <iostream>
    using namespace std;

    float odostartone;
    float odoendone;
    float gallonsone;
    float odostarttwo;
    float odoendtwo;
    float gallonstwo;
    float odostartthree;
    float odoendthree;
    float gallonsthree;

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    12
    Yea, You need more tho...

    You can have comma's and run them rowed instead of collums

    float odostartone,odostarttwo,etc..
    but whatever works for you.

    You also need distance1,2,3(or miles1,2,3) and MPG1(2,3) etc

    cuz it's Miles/Gallons = MPG

    But without proper instructions your pretty much stumped.. you can set it up so you can enter odometer start and finish 3 times each.... as well ad miles drove and it will display everything.. but it's odd he just gave you a picture and vague instructions such as.. 3 lists of odometer start end, miles, gallons and mpg.. I gotta go to bed. So i hope someone else can help. If not I'll add more tomorrow
    Last edited by DigitalBear; 09-23-2008 at 11:27 PM.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > everyone says simple but I am Very new too this....all I know how to do is little things....like cout, setw, fin, fout, endl, and other small functions
    So start with that, as in

    cout << "Enter start odometer";
    cin >> start;


    When you've input 3 values (as described), you have enough info to calculate the other two values.

    Can you do that much?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM