Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

%3Cp%20class%3D%22c1%20c1%22%3EWrite%20a%20program%20for%20a%20small%20theater%2

ID: 3552622 • Letter: #

Question

%3Cp%20class%3D%22c1%20c1%22%3EWrite%20a%20program%20for%20a%20small%20theater%20to%20use%20to%20keep%0Atrack%20of%20which%20seats%20have%20been%20reserved%20and%20which%20seats%20are%0Aavailable.%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%20c1%22%3EThe%20program%20should%20begin%20by%20reading%20%3Ci%20class%3D%0A%22c2%22%3Eseating.txt%3C%2Fi%3E%2C%20which%20contains%20information%20stored%20from%20the%0Aprevious%20execution%20of%20the%20program%2C%20and%20displaying%20the%20seating%20chart%0Ato%20the%20screen%20so%20the%20user%20can%20see%20which%20seats%20are%20available%20and%0Awhich%20are%20not.%20Use%20a%202D%20array%20to%20represent%20the%20theater%20seating%20with%0Aeach%20row%20of%20the%20theater%20corresponding%20to%20each%20row%20of%20the%20array%20and%0Aeach%20seat%20corresponding%20to%20a%20column%20in%20the%20array.%20The%20theater%20has%0Athirty%20seats%20in%20a%20row%20and%20ten%20rows.%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%20c1%22%3EThe%20first%20time%20the%20program%20is%0Aexecuted%2C%20%3Ci%20class%3D%22c2%22%3Eseating.txt%3C%2Fi%3E%26nbsp%3Bshould%20be%0Ainitialized%20to%20hold%20the%20price%20per%20seat%20on%20one%20line%20followed%20by%20all%0Azeros%20for%20the%20seats%3B%20the%20program%20should%20then%20display%20the%20following%0Awhere%20the%20first%20line%20is%20a%20header%20to%20help%20track%20the%20seat%20number%20and%0Athe%20numbers%20along%20the%20left%20are%20used%20to%20track%20the%20row%20number.%3C%2Fp%3E%0A%3Ctable%20width%3D%22100%25%22%20cellpadding%3D%220%22%20cellspacing%3D%220%22%20class%3D%0A%22boxedsection%20Exact%20Output%20c11%20c11%22%3E%0A%3Ctbody%20class%3D%22c7%22%3E%0A%3Ctr%20class%3D%22c6%22%3E%0A%3Ctd%20class%3D%22boxedsection%20header%20Exact%20Output%20c6%20c5%22%3E%0A%3Ctable%20width%3D%22100%25%22%20class%3D%22verbatimcodeheader%20c5%20c8%22%3E%0A%3Ctbody%20class%3D%22c7%22%3E%0A%3Ctr%20class%3D%22c6%22%3E%0A%3Ctd%20width%3D%2220%22%20class%3D%22c4%20c5%22%3E%3Ca%20href%3D%0A%22https%3A%2F%2Fwiki.cs.astate.edu%2Findex.php%2FFile%3ASampleoutput.png%22%20class%3D%0A%22image%20c3%20c4%22%20title%3D%22Sampleoutput.png%22%3E%3Cimg%20alt%3D%22%22%20src%3D%0A%22https%3A%2F%2Fwiki.cs.astate.edu%2Fimages%2Fthumb%2FSampleoutput.png%2F20px-Sampleoutput.png%22%0Awidth%3D%2220%22%20height%3D%2220%22%20border%3D%220%22%20class%3D%22c2%20c3%22%20%2F%3E%3C%2Fa%3E%3C%2Ftd%3E%0A%3Ctd%20class%3D%22c4%20c5%22%3EThe%20output%20of%20your%20program%20should%20look%20exactly%0Alike%20this.%20Data%20values%20may%20differ.%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3C%2Ftbody%3E%0A%3C%2Ftable%3E%0A%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3Ctr%20class%3D%22c6%22%3E%0A%3Ctd%20class%3D%22c5%22%3E%0A%3Cdiv%20class%3D%22boxedsection%20body%20Exact%20Output%20c10%20c10%22%3E%0A%3Cdiv%20dir%3D%22ltr%22%20class%3D%22mw-geshi%20c9%20c10%22%3E%0A%3Cdiv%20class%3D%22text%20source-text%20c8%20c10%22%3E%0A%3Cpre%20class%3D%22de1%20c7%20c9%22%3E%0A%20%20%20123456789012345678901234567890%0A%201%20000000000000000000000000000000%0A%202%20000000000000000000000000000000%0A%203%20000000000000000000000000000000%0A%204%20000000000000000000000000000000%0A%205%20000000000000000000000000000000%0A%206%20000000000000000000000000000000%0A%207%20000000000000000000000000000000%0A%208%20000000000000000000000000000000%0A%209%20000000000000000000000000000000%0A10%20000000000000000000000000000000%0A%3C%2Fpre%3E%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3C%2Ftbody%3E%0A%3C%2Ftable%3E%0A%3Cp%20class%3D%22c1%20c1%22%3E%3Cbr%20%2F%3E%0AThe%20program%20should%20then%20allow%20the%20user%20to%20choose%20from%20the%20following%0Aoptions.%3C%2Fp%3E%0A%3Ctable%20width%3D%22100%25%22%20cellpadding%3D%220%22%20cellspacing%3D%220%22%20class%3D%0A%22boxedsection%20Exact%20Output%20c11%20c11%22%3E%0A%3Ctbody%20class%3D%22c7%22%3E%0A%3Ctr%20class%3D%22c6%22%3E%0A%3Ctd%20class%3D%22boxedsection%20header%20Exact%20Output%20c6%20c5%22%3E%0A%3Ctable%20width%3D%22100%25%22%20class%3D%22verbatimcodeheader%20c5%20c8%22%3E%0A%3Ctbody%20class%3D%22c7%22%3E%0A%3Ctr%20class%3D%22c6%22%3E%0A%3Ctd%20width%3D%2220%22%20class%3D%22c4%20c5%22%3E%3Ca%20href%3D%0A%22https%3A%2F%2Fwiki.cs.astate.edu%2Findex.php%2FFile%3ASampleoutput.png%22%20class%3D%0A%22image%20c3%20c4%22%20title%3D%22Sampleoutput.png%22%3E%3Cimg%20alt%3D%22%22%20src%3D%0A%22https%3A%2F%2Fwiki.cs.astate.edu%2Fimages%2Fthumb%2FSampleoutput.png%2F20px-Sampleoutput.png%22%0Awidth%3D%2220%22%20height%3D%2220%22%20border%3D%220%22%20class%3D%22c2%20c3%22%20%2F%3E%3C%2Fa%3E%3C%2Ftd%3E%0A%3Ctd%20class%3D%22c4%20c5%22%3EThe%20output%20of%20your%20program%20should%20look%20exactly%0Alike%20this.%20Data%20values%20may%20differ.%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3C%2Ftbody%3E%0A%3C%2Ftable%3E%0A%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3Ctr%20class%3D%22c6%22%3E%0A%3Ctd%20class%3D%22c5%22%3E%0A%3Cdiv%20class%3D%22boxedsection%20body%20Exact%20Output%20c10%20c10%22%3E%0A%3Cdiv%20dir%3D%22ltr%22%20class%3D%22mw-geshi%20c9%20c10%22%3E%0A%3Cdiv%20class%3D%22text%20source-text%20c8%20c10%22%3E%0A%3Cpre%20class%3D%22de1%20c7%20c9%22%3E%0A1.%20%20Initialize%20seating%20for%20new%20performance.%0A2.%20%20View%20seating%20chart.%0A3.%20%20Reserve%20seats.%0A4.%20%20Calculate%20tickets%20remaining%20in%20row.%0A5.%20%20Calculate%20tickets%20remaining%20in%20theater.%0A6.%20%20Calculate%20total%20tickets%20sold.%0A7.%20%20Calculate%20ticket%20sales.%0A8.%20%20Exit%20program.%0A%3C%2Fpre%3E%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%3C%2Ftbody%3E%0A%3C%2Ftable%3E%0A%3Cp%20class%3D%22c1%20c1%22%3EThe%26nbsp%3B%3Ctt%20class%3D%22c12%22%3Emain%3C%2Ftt%3E%26nbsp%3Bfunction%0Ashould%20interact%20with%20the%20user%20and%20call%20functions%20as%20needed%3B%20all%0Ainput%20should%20be%20validated.%20There%20should%20be%20no%20file%20I%2FO%20within%0Afunction%26nbsp%3B%3Ctt%20class%3D%22c12%22%3Emain%3C%2Ftt%3E.%20The%20program%20should%0Acontinue%20to%20execute%20until%20the%20user%20chooses%20to%20exit%20the%20program.%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%20c1%22%3EWhenever%20there%20has%20been%20a%20change%20to%20the%20seating%0Achart%2C%20the%20program%20should%20display%20the%20updated%20seating%20chart.%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%20c1%22%3EEstablish%20a%20global%20constant%2C%26nbsp%3B%3Ctt%20class%3D%0A%22c12%22%3EROWS%3C%2Ftt%3E%2C%20for%20the%20number%20of%20rows%20as%20well%20as%20a%20global%0Aconstant%2C%26nbsp%3B%3Ctt%20class%3D%22c12%22%3ESEATS%3C%2Ftt%3E%2C%20for%20the%20number%20of%0Aseats.%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%20c1%22%3EInclude%20definitions%20for%20the%20following%20function%0Aprototypes%20%E2%80%94%20you%20may%20also%20create%20additional%20%22helper%22%20functions%20if%0Ayou%20wish%2C%20but%20you%20are%26nbsp%3B%3Ci%20class%3D%22c2%22%3Erequired%3C%2Fi%3E%26nbsp%3Bto%0Ainclude%20the%20functions%20described%20below%3A%3C%2Fp%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Evoid%20initializeSeating%0A(int%20theater%5B%5D%5BSEATS%5D%2C%20double%26amp%3B%20ticketPrice)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EPrompts%20user%20for%20cost%20per%20ticket.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EInitializes%20all%20elements%20in%20the%202D%20array%20to%0Azero.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Evoid%20displaySeating%0A(const%20int%20theater%5B%5D%5BSEATS%5D)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EDisplays%20seating%20chart%20to%20screen.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Evoid%20readSeating%20(int%0Atheater%5B%5D%5BSEATS%5D%2C%20double%20%26amp%3BticketPrice)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EAttempts%20to%20open%20the%20file%20containing%20the%20saved%0Aticket%20price%20and%20seating%20chart.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20the%20file%20exists%2C%20the%20cost%20per%20ticket%20and%0Aseating%20information%20is%20read.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20the%20file%20does%20not%20exist%2C%0Afunction%26nbsp%3B%3Ccode%20class%3D%0A%22c12%20c13%22%3EinitializeSeating%3C%2Fcode%3E%26nbsp%3Bis%20called.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Evoid%20storeSeating%20(const%0Aint%20theater%5B%5D%5BSEATS%5D%2C%20double%20ticketPrice)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EThe%20contents%20of%26nbsp%3B%3Ci%20class%3D%0A%22c2%22%3Eseating.txt%3C%2Fi%3E%26nbsp%3Bis%20overwritten%20with%20the%20current%0Adata.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EThe%20first%20line%20of%20the%20file%20contains%20the%20ticket%0Aprice.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EThe%20seating%20chart%20information%20is%20stored%20one%20row%0Aper%20line%20with%20a%20space%20between%20each%20seat.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Eint%20displayMenu%0A(void)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EDisplays%20the%20user's%20options%20to%20the%20screen.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EThe%20user%20is%20prompted%20for%20a%20choice%2C%20which%20is%0Areturned%20from%20the%20function.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Eint%0AcalcTicketsAvailableInRow(const%20int%20theater%5B%5D%5BSEATS%5D%2C%20int%0Arow)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3ECalculates%20and%20returns%20the%20number%20of%20tickets%0Aavailable%20in%20the%20row.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EThe%20function%20performs%20no%20input%20or%20output.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3ENOTE%3A%20The%20value%20of%26nbsp%3B%3Ccode%20class%3D%0A%22c12%20c13%22%3Erow%3C%2Fcode%3E%26nbsp%3Bis%20expected%20to%20be%20a%26nbsp%3B%3Ci%20class%3D%0A%22c2%22%3Ehuman-friendly%3C%2Fi%3E%26nbsp%3Brow%20number%2C%26nbsp%3B%3Cb%20class%3D%0A%22c18%22%3Enot%3C%2Fb%3E%26nbsp%3Ban%20array%20index.%20You%20will%20need%20to%20take%20this%20into%0Aaccount!%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Eint%0AcalcTotalTicketsSold(const%20int%20theater%5B%5D%5BSEATS%5D)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3ECalculates%20and%20returns%20the%20total%20number%20of%0Atickets%20that%20have%20been%20sold.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EThe%20function%20performs%20no%20input%20or%20output.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cdl%20class%3D%22c14%20c15%22%3E%0A%3Cdt%20class%3D%22c13%20c14%22%3E%3Ccode%20class%3D%22c12%20c13%22%3Evoid%20reserveSeats(int%0Atheater%5B%5D%5BSEATS%5D)%3B%3C%2Fcode%3E%3C%2Fdt%3E%0A%3C%2Fdl%3E%0A%3Cul%20class%3D%22c16%20c17%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EPrompts%20the%20user%20for%20the%20number%20of%20seats%20to%20be%0Areserved%3B%20no%20more%20than%26nbsp%3B%3Ctt%20class%3D%22c12%22%3ESEATS%3C%2Ftt%3E%26nbsp%3Bmay%20be%0Areserved%20at%20a%20time.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20single%20seat%20reservation%0A%3Cul%20class%3D%22c17%20c19%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EPrompts%20the%20user%20for%20the%20preferred%20seat%3B%20input%0Avalidation%20is%20employed.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20the%20preferred%20seat%20is%20available%2C%20the%20seat%20is%0Areserved%20by%20replacing%20the%20value%20of%20zero%20with%20a%20value%20of%20one.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20a%20ticket%20for%20the%20seat%20has%20already%20been%20sold%2C%0Athe%20user%20is%20informed.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20multiple%20seat%20reservation%0A%3Cul%20class%3D%22c17%20c19%22%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EFor%20simplicity%2C%20a%20multiple%20seat%20reservation%0Awill%20require%20all%20seats%20to%20be%20on%20the%20same%20row.%20No%20more%0Athan%26nbsp%3B%3Ctt%20class%3D%22c12%22%3ESEATS%3C%2Ftt%3E%26nbsp%3Bnumber%20of%20seats%20may%20be%0Areserved%20at%20a%20time.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EPrompts%20the%20user%20for%20the%20location%20of%20the%20first%0Aseat.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EWhen%20validating%20input%2C%20consider%20the%20possibility%0Athat%20the%20first%20seat%20chosen%20will%20not%20allow%20for%20the%20requested%20number%0Aof%20seats%20(e.%20g.%2010%20seats%20are%20requested%20with%20a%20first%20seat%20number%20of%0A25).%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20the%20requested%20number%20of%20seats%20beginning%20with%0Athe%20first%20seat%20selected%20are%20available%2C%20the%20seats%20are%20reserved%20by%0Areplacing%20the%20value%20of%20zero%20with%20a%20value%20of%20one%20in%20each%20element%20of%0Athe%20array%20representing%20the%20group%20of%20seats.%3C%2Fli%3E%0A%3Cli%20class%3D%22c15%20c16%22%3EIf%20all%20the%20seats%20are%20not%20available%2C%20the%20user%20is%0Ainformed.%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3C%2Fli%3E%0A%3C%2Ful%3E%0A

Explanation / Answer

If you compile and run this example you'll get a box of numbers like this: