In over my head...needhelp

This is a discussion on In over my head...needhelp within the C++ Programming forums, part of the General Programming Boards category; Hello...I am a beginner with C++ programming and am trying to self teach myself enums and strings. I am doing ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    5

    In over my head...needhelp

    Hello...I am a beginner with C++ programming and am trying to self teach myself enums and strings. I am doing a tutorial problem out of book someone gave me and can't even figure out how to start it.

    If anyone can help, it would be greatly appreciate it.

    The problem...
    Calculate and print the total cost of a round trip ticket for each line in the data file.

    The input file (travel.txt) has the following layout:

    Price (the cost of the ticket for that particular trip, it should be doubled if it is one way)
    Travel tax (the tax for whole trip, both round trip and one way pay that tax)
    Sales tax (the percentage tax on the total price of the ticket, as 6%, 10%, …etc.)
    Train or Bus name (GH, AT)
    Origin City (can be one or two words)
    One-way/roundtrip (1 means one way, 2 means round trip)
    Destination City (can be one or two words)

    These are examples of some trips:
    //first line is price, then tax, then sales tax, GH name of busline, then city, 1 one way – 2 round trip, then destination.
    99.99 10.00 0.06 GH Charleston 1 Daytona Beach
    143.95 13.00 0.06 AT Chicago 2 New York

    The program has to read the file one record at a time, then print the itinerary for that trip and calculate the ticket price as a round trip ticket (even if it was given as a one-way trip in the file.) The program will read the code letters for the name of the form of travel from the input and then expand them to the full name in the output. For example, GH, will become Greyhound Busline, and AT will print AmTrack. The program also will read the name of the city from the input, then it will abbreviate it. If the city is one word, then the abbreviation will be the first and last letters of the word. Both letters should be capitalized. If the city is two words, then the abbreviation will be the first letter of each word.

    A sample output for 99.99 10.00 0.06 GH Charleston 1 Daytona Beach is:

    The round trip price from CN to DB using Greyhound Busline is $222.58

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,401
    Well, you can start by writing a program that reads from file in the given format and prints what was read so you can check that you did that part correctly.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program won't continue
    By cmsc in forum C Programming
    Replies: 2
    Last Post: 10-17-2009, 02:10 PM
  2. Looking for a way to store listbox data
    By Welder in forum C Programming
    Replies: 20
    Last Post: 11-01-2007, 11:48 PM
  3. Cant head insert on doubly linked list
    By aciarlillo in forum C++ Programming
    Replies: 4
    Last Post: 09-18-2005, 11:31 AM
  4. Can't figure out problem with code
    By Beast() in forum C Programming
    Replies: 4
    Last Post: 04-16-2005, 05:27 PM
  5. Linked List Help
    By Perverse in forum C++ Programming
    Replies: 3
    Last Post: 02-22-2005, 07:33 AM

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