Thread: Need help starting a monster of a program.

  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    13

    Need help starting a monster of a program.

    Hey everyone this is the last programming assignment of the semester and it's quite the doozy. I don't even understand how to start so if anyone could give some helpful advice I would appreciate it very much. By the way the instructions are kind of a long read, sorry about that. If it helps I'm only planning on doing the ticket sales since so you can just read everything having to do with that. I included the instructions on how to code the ticketsales section of the program in the attachment. This is the sample input :
    15 25 200
    3 10
    17.99 22.99 109.99
    100 2 4
    5.99 99.99 20.00 49.99
    10 10 10 10 10 10 10 10 10 10
    3.99 5.99 7.99 8.00 5.00 5.00 5.00 6.00 7.00 9.99
    5
    BUY TICKET 8
    BUY TICKET 10
    BUY TICKET 1
    BUY TICKET 3
    TOTAL REVENUE

    And this is the sample output: SOLD TICKETS 200 - 207
    SOLD TICKETS 208 - 217
    SOLD TICKETS 218 - 218
    SOLD TICKETS 219 - 221
    TOTALREVENUE is $3550.00



    Thank you in advance!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Doing well on this assignment seems to be as much about how you approach this problem as anything. As the instructions suggest, you need to be organized, methodical and modular in your approach. Don't just try to write 500 lines of code that just "solve it". Consider when it's due and how much time you really have to work on this, keeping in mind whether you have a job, family duties, homework and final projects/exams for other classes, and a little bit of fun time to keep your sanity. Oh, and sleep, if you're one of those people. Honestly, you could probably crank out just ticket sales in a day (~8 hours) or less if you stick to a good design and development process. Consider level 2 or 3 if it's worth more points.

    Start by printing out the instructions and highlighting the important parts. The first step is to understand the problem. Think about how you would do this if you had to do it yourself on paper, or if you were the computer. If you can't do it, you can't program a computer to do it. Then, grab some paper and a pencil and start writing down key info and ideas. Write down the high-level tasks you need to accomplish (note, some of this comes directly from the assignment directions). Break those tasks into sub tasks. For example break the task "read input file" into "open file", "read pre-sale ticket price, at-door ticket price and number of pre-sale tickets".

    Next take your tasks, data structures, etc and start turning them into pseudo code. Remember, be modular and work on one task at a time. Consider the rough data structures you need: arrays, structs and what elements they contain, etc. Don't get caught up on int vs float vs double just yet, focus on the purpose of each variable, which you can later use as a descriptive variable name.
    Code:
    double x  // WTF is this for?
    auction_item_price  // this is much clearer, we'll worry about specific type when we actually start coding, but we know price is a number of some sort
    This is where you get a rough idea for what functions you'll use, what data they need, etc. You'll also work on the overall program logic without having to worry about syntax, spelling, punctuation, exact data types, etc just yet.

    Once you have the whole thing fleshed out in pseudo code, start turning that into C code. Work in small chunks, 5-10 lines of code at a time. Compile (with maximum warning level), fix all warnings and errors, then test it and fix any bugs. Don't move on to the next section until all previous sections are bug-free. It's okay to have a bunch of "test" code that you will throw away before you turn it in. But keep it around in test functions or a test file you can compile in, in case you finish sooner and decide you want to go up a level of difficulty. Then you can re-run your tests and make sure you didn't break some older code by adding newer code. Make sure you check all IO functions (fopen, fscanf, etc) and any other functions that provide error info, for errors and act accordingly. Using perror to print an error message is good, and consider whether you must exit, or you can "recover" from the error.

    I would start with the input function. Make sure you can read the whole input file correctly and print it back out, something like. Work on one line at a time and test after each new line you read
    Code:
    presale_ticket_price: 15 at_door_ticket_price: 25 num_presale_tickets: 200
    num_auction_items: 3 min_bid_increment: 10.00
    ...
    read event: BUY TICKET 8
    Make up a dozen or so different test files (different size, number of items, actions, etc) you can use to make sure you always read input correctly, unless the professor provides test files for you.

    Once you have that done, move onto functions like count_ticket_revenue, count_auction_revenue, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help on Starting a Program!
    By Sharpenel in forum C Programming
    Replies: 3
    Last Post: 10-22-2012, 03:06 AM
  2. Starting C++;First Program
    By Caliban in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2009, 01:41 PM
  3. Starting a new program
    By histevenk in forum C++ Programming
    Replies: 28
    Last Post: 10-15-2007, 04:11 PM
  4. Starting a program
    By mcgeady in forum C++ Programming
    Replies: 3
    Last Post: 02-25-2006, 12:52 PM
  5. Starting the program
    By vasanth in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 04:51 AM

Tags for this Thread