Thread: Need help!!

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    4

    Cool Need help!!

    i just got this problem for an assignment and have no idea how to do it.... can anyone help me!!!!!!!
    Problem:
    A theatre seating chart is implemented as a two-dimensional array of ticket prices, like this:
    10 10 10 10 10 10 10 10 10 10
    10 10 10 10 10 10 10 10 10 10
    10 10 10 10 10 10 10 10 10 10
    10 10 20 20 20 20 20 20 10 10
    10 10 20 20 20 20 20 20 10 10
    10 10 20 20 20 20 20 20 10 10
    20 20 30 30 40 40 30 30 20 20
    20 30 30 40 50 50 40 30 30 20
    30 40 50 50 50 50 50 50 40 30
    Write a program that prompts users to pick either a seat or a price. Mark sold seats by changing the price to 0. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price starting at the front and working to the back of the theatre. Make sure you write your program using well defined functions.

    You are to hand in:
    · Source code (well documented)
    · Input file (if used)
    · Sample user files to test valid and invalid choices
    · Hierarchy Chart
    · User Guide

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Devoted my life to programming...

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Announcements - C++ Programming

    Announcements - General Programming Boards

    I dunno - it's a bit late in the semester for you to start catching up with everyone else. Perhaps just drop the course now.
    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.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    4
    ohh sorry.. well i have a little bit done but i just cant finish it.. this is what i have
    insert
    Code:
    #include <iostream> #include <iomanip> using namespace std; int main () { int ROWS = 9; int ISLES = 10; int counts[ROWS][ISLES] = { { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 }, { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 }, { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 }, { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 }, { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 }, { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 }, }; } void getdata (const counts[][], int ROW, int ISLE, int pick) { cout<<"Press (1) if you would like to pick a seat and press (2) if you would like to enter a price: "<<endl; cin>>pick; if (pick == 1) { cout<<"Please enter the row you would like to sit in: "<<endl; cin>>ROW; cout<<"Please enter the isle you would like to sit in: "<<endl; cin>>ISLE; } else if (pick ==2) { cout<<"Please enter the price: "<<endl; cin>>price; } }

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    48
    Your getdata() method doesn't actually do anything, there is no value returned, nor are any of the params non local. I believe you need to modify that method to have a return value representing the chosen tickets price.

    Also, you are double creating the 2d matrix. Either move its declaration inside the method, instead of passing it as a param, or pass it by reference ( and an ampersand to the function declaration ).

    Finally, don't use all caps for non const/global declarations, this is a pretty universally established convention.

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Regardless of what happens in your GetData function, it will never happen at all as you do not call it.
    return 0 from main.
    This is an oft seen assignment and i think there is a lot of advice in the board history if you care to look, but one tip for you is score extra marks by implementing a file read function to assign the array values, instead of your hardcoded version its an easy win and might help you pick a mark or two up if the rest of your work bombs...the tutor put this as a possibility in your criteria, you should interpret things like that as opportunities to score.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed