Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7, Problem 20PC
Program Plan Intro
Seating in Theatre
Program Plan:
- Include header file section.
- Declare the global constants for number of rows and columns
- Declare the function prototypes.
- Inside main() function,
- Declare the required variables for theater seating.
- The outer for loop executes until the number of rows fails and the inner for loop executes until the number of columns fails.
- Prompt the user to enter the ticket price for each row.
- Use the do…while loop to display the menu options available using displayMenu() function.
- Inside the loop, use the switch…case expression to select the case based upon the user choice.
- If the user choice is “1”, then call the function displaySeats() to display the number of seats.
- If the user choice is “2”, then call the function displayPrices() to display the seat prices.
- If the user choice is “3”, then call the function displaySales() to display the total number of sales.
- If the user choice is “4”, then call the function purchaseTicket() to display the number of tickets purchased.
- If the user choice is “5”, then exit from the program.
- If the user enters the choice other than 5, then while loop executes until the user enters correct choice.
- In function displayMenu(),
- Print the header with available menu options.
- In function getChoice(),
- Validate the choice entered by the user. If validation fails, ask the user to re-enter the choice.
- In function displaySeats(),
- This function uses two for loops to print the theater seating with sold and available tickets on theatre.
- In function displayPrices(),
- This function uses two for loops to print the ticket prices for each row.
- In function purchaseTicket(),
- Prompt the user to enter the input “yes” or “no” to view the seating details of chart.
- Convert the input to uppercase and call the function displaySeats() to display number of seats in theatre.
- Use do..while loop to enter the desired row number.
- Validate using while loop whether the entered row number is from 1 to 15. Otherwise ask the user to re-enter the input.
- Validate using while loop whether the entered seat number is from 1 to 30. Otherwise ask the user to re-enter the input.
- The if condition validates whether the seat is marked with “#” or “*”.
- If the seat is market with “#” then the seat is available print the user with the message “purchase confirmed”.
- Calculate the patron’s ticket total and total price of tickets that has been sold.
- If the seat is market with “*” otherwise the seat is taken by some other user.
- Display the total price of tickets.
- In function displayPrices(),
- This function prints the total sales upto the current date.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Program
This program should be designed and written by a team of students. Here are some suggestions: o One student should design function main, which will call the other functions in the program. The remainder of the functions will be designed by other members of the team. o The requirements of the program should be analyzed so each student is given about the same work load. o The parameters and return types of each function should be decided in advance. o The program can be implemented as a multi-file program, or all the functions can be cut and pasted into the main file. Here is the assignment: Write a program that can be used by a small theater to sell tickets for performances. The theater’s auditorium has 15 rows of seats, with 30 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. Seats that are taken are represented by an * symbol, and seats…
This program should be designed and written by a team of students. Here are some suggestions: o One student should design function main, which will call the other functions in the program. The remainder of the functions will be designed by other members of the team. o The requirements of the program should be analyzed so each student is given about the same work load. o The parameters and return types of each function should be decided in advance. o The program can be implemented as a multi-file program, or all the functions can be cut and pasted into the main file. Here is the assignment: Write a program that can be used by a small theater to sell tickets for performances. The theater’s auditorium has 15 rows of seats, with 30 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. Seats that are taken are represented by an * symbol, and seats…
Chapter 7 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 7.3 - Define the following arrays: A) empNums, a...Ch. 7.3 - Prob. 7.2CPCh. 7.3 - Prob. 7.3CPCh. 7.3 - Prob. 7.4CPCh. 7.3 - What is array bounds checking? Does C++ perform...Ch. 7.3 - What is the output of the following code? int...Ch. 7.3 - The following program skeleton contains a...Ch. 7.7 - Given the following array definition: int values[]...Ch. 7.7 - Given the following array definition: int nums[5]...Ch. 7.7 - Prob. 7.12CP
Ch. 7.7 - What is the output of the following code? (You may...Ch. 7.8 - Prob. 7.14CPCh. 7.8 - Prob. 7.15CPCh. 7.8 - When used as function arguments, are arrays passed...Ch. 7.8 - What is the output of the following program? (You...Ch. 7.8 - The following program skeleton, when completed,...Ch. 7.10 - Prob. 7.19CPCh. 7.10 - How many elements are in the following array?...Ch. 7.10 - Write a statement that assigns the value 56893.12...Ch. 7.10 - Prob. 7.22CPCh. 7.10 - Prob. 7.23CPCh. 7.10 - Fill in the table below so that it shows the...Ch. 7.10 - Write a function called displayArray7. The...Ch. 7.10 - A video rental store keeps DVDs on 50 racks with...Ch. 7.12 - Prob. 7.27CPCh. 7.12 - Write a definition statement for a vector named...Ch. 7.12 - Prob. 7.29CPCh. 7.12 - Write a definition statement for a vector named...Ch. 7.12 - Prob. 7.31CPCh. 7.12 - snakes is a vector of doubles, with 10 elements....Ch. 7 - Prob. 1RQECh. 7 - Look at the following array definition: int...Ch. 7 - Why should a function that accepts an array as an...Ch. 7 - Prob. 4RQECh. 7 - Prob. 5RQECh. 7 - Prob. 6RQECh. 7 - Prob. 7RQECh. 7 - Assuming that numbers is an array of doubles, will...Ch. 7 - Prob. 9RQECh. 7 - Prob. 10RQECh. 7 - How do you establish a parallel relationship...Ch. 7 - Prob. 12RQECh. 7 - When writing a function that accepts a...Ch. 7 - What advantages does a vector offer over an array?Ch. 7 - Prob. 15RQECh. 7 - The size declarator must be a(n) ________ with a...Ch. 7 - Prob. 17RQECh. 7 - Prob. 18RQECh. 7 - The number inside the brackets of an array...Ch. 7 - C++ has no array ________ checking, which means...Ch. 7 - Starting values for an array may be specified with...Ch. 7 - If an array is partially initialized, the...Ch. 7 - If the size declarator of an array definition is...Ch. 7 - By using the same _________ for multiple arrays,...Ch. 7 - Prob. 25RQECh. 7 - Prob. 26RQECh. 7 - To pass an array to a function, pass the ________...Ch. 7 - A(n) _______ array is like several arrays of the...Ch. 7 - Its best to think of a two-dimensional array as...Ch. 7 - Prob. 30RQECh. 7 - Prob. 31RQECh. 7 - When a two-dimensional array is passed to a...Ch. 7 - The ________________ is a collection of...Ch. 7 - The two types of containers defined by the STL are...Ch. 7 - The vector data type is a(n) ____________...Ch. 7 - Prob. 36RQECh. 7 - To store a value in a vector that docs nor have a...Ch. 7 - To determine the number of elements in a vector,...Ch. 7 - Use the _______________ member function to remove...Ch. 7 - To completely clear the contents of a vector, use...Ch. 7 - Prob. 41RQECh. 7 - Prob. 42RQECh. 7 - In a program, you need to store the identification...Ch. 7 - Prob. 44RQECh. 7 - In a program, you need to store the populations of...Ch. 7 - The following code totals the values in two...Ch. 7 - Prob. 47RQECh. 7 - Prob. 48RQECh. 7 - Prob. 49RQECh. 7 - Prob. 50RQECh. 7 - Prob. 51RQECh. 7 - T F The individual elements of an array are...Ch. 7 - T F The first element in an array is accessed by...Ch. 7 - Prob. 54RQECh. 7 - Prob. 55RQECh. 7 - T F Subscript numbers may be stored in variables.Ch. 7 - T F You can write programs that use invalid...Ch. 7 - Prob. 58RQECh. 7 - T F The values in an initialization list are...Ch. 7 - T F C++ allows you to partially initialize an...Ch. 7 - T F If an array is partially initialized, the...Ch. 7 - T F If you leave an element uninitialized, you do...Ch. 7 - T F If you leave out the size declarator of an...Ch. 7 - T F The uninitialized elements of a string array...Ch. 7 - T F You cannot use the assignment operator to copy...Ch. 7 - Prob. 66RQECh. 7 - T F To pass an array to a function, pass the name...Ch. 7 - T F When defining a parameter variable to hold a...Ch. 7 - T F When an array is passed to a function, the...Ch. 7 - T F A two-dimensional array is like several...Ch. 7 - T F Its best to think of two-dimensional arrays as...Ch. 7 - T F The first size declarator (in the declaration...Ch. 7 - T F Two-dimensional arrays may be passed to...Ch. 7 - T F C++ allows you to create arrays with three or...Ch. 7 - Prob. 75RQECh. 7 - T F To use a vector, you must include the vector...Ch. 7 - T F vectors can report the number of elements they...Ch. 7 - T F You can use the [ ] operator to insert a value...Ch. 7 - T F If you add a value to a vector that is already...Ch. 7 - int sixe; double values [size];Ch. 7 - Prob. 81RQECh. 7 - Prob. 82RQECh. 7 - Prob. 83RQECh. 7 - int numbers[8] ={1,2, , ,4, , 5};Ch. 7 - float ratings[] ;Ch. 7 - Prob. 86RQECh. 7 - Prob. 87RQECh. 7 - Prob. 88RQECh. 7 - void showValues(int nums [4][]) { For (rows = 0;...Ch. 7 - Prob. 90RQECh. 7 - Largest/Smallest Array Values Write a program that...Ch. 7 - Rainfall Statistics Write a program that lets the...Ch. 7 - Chips and Salsa Write a program that lets a maker...Ch. 7 - Larger than n In a program, write a function that...Ch. 7 - Monkey Business A local zoo wants to keep track of...Ch. 7 - Rain or Shine An amateur meteorologist wants to...Ch. 7 - Number Analysis Program Write a program that asks...Ch. 7 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 7 - Payroll Write a program that uses the following...Ch. 7 - Drivers License Exam The local Drivers License...Ch. 7 - Prob. 11PCCh. 7 - Grade Book A teacher has five students who have...Ch. 7 - Lottery Application Write a program that simulates...Ch. 7 - vector Modification Modify the National Commerce...Ch. 7 - World Series Champions If you have downloaded this...Ch. 7 - Name Search If you have downloaded this books...Ch. 7 - Tic-Tac-Toe Game Write a program that allows two...Ch. 7 - 2D Array Operations Write a program that creates a...Ch. 7 - Prob. 20PC
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered in the unit so far, including the usage of variables, input and output, data types, selection, iteration, functions and data structures. Above all else, it tests your ability to design and then implement a solution to a problem using these concepts. Assignment Overview You are required to design and implement a "Word Game" program in which the user must identify a randomly selected "password" from a list of 8 words. The 8 words are selected at random from the list of 100 words in the starter file (word_game.py) provided to you with this assignment brief. Please use the starter file as the basis of your assignment code. The user has 4 attempts in which to guess the password. Whenever they guess incorrectly, they are told how many of the letters are the same between the word they guessed and the password. For example, if the password is "COMEDY" and…arrow_forwardC++ Languagearrow_forward- PROJECT REQUIREMENTS Choose a programming project application to be developed, then design and implement the programming elements according to your creativity using C++ language. The application must demonstrate the integration of file I/O, records(struct), array and functions. You may follow the general framework for the implementation phase as highlighted below: Read data from file. Store data into a struct array. Process the data using functions. You may pass variables, one dimensional array, two dimensional array, struct variable or struct array to functions, where appropriate. Display the output to the screen, where appropriate. Write the output file, where appropriate. O O O O Oarrow_forward
- Student Registration System is an approach that enables colleges and universities to better supervise a growing number of enrollments. Create a menu system for registration program in c++ that asking an input based on the choices below. If the input is A then the program will ask for name and program (course) store in two arrays, if B then the program will display all the data stored on the array and the program will be terminated only if the input is E. Apply also function on the program: Menu System – 1st Way of Function Add Student – 4th Way of Function Example: REGISTRATION SYSTEM: A - Add Student B - View ALL E - Exit Choose: A Name: John Lloyd Program: CpE REGISTRATION SYSTEM: A - Add Student B - View ALL E - Exit Choose: B Name Program…arrow_forwardStudent Registration System is an approach that enables colleges and universities to better supervise a growing number of enrollments. Create a menu system for registration program in c++ that asking an input based on the choices below. If the input is A then the program will ask for name and program (course) store in two arrays, if B then the program will display all the data stored on the array and the program will be terminated only if the input is E. Apply also function on the program: Menu System – 1st Way of Function Add Student – 4th Way of Function Example: REGISTRATION SYSTEM: A - Add Student B - View ALL E - Exit Choose: A Name: Sebastian Program: CE REGISTRATION SYSTEM: A - Add Student B - View ALL E - Exit Choose: B Name Program Carlo - CE Sevi - CEarrow_forwardPython question Application: Python Fragment Formulation (Q1 – Q4) In this group of questions you are asked to produce short pieces of Python code. When you are asked to "write a Python expression" to complete a task, you can either give the expression in one line or break down the task into several lines. The last expression you write must represent the required task. Question 1 (Reduce parentheses) Give an equivalent version of this expression by removing as many redundant parentheses as possible, without expanding the brackets or simplifying. (x**(2**y))+(y*((z+x)**3)) Question 2 (Translate arithmetic concept into Python) You are given a list of numbers, named numbers, containing 3 integers. Write a python expression (one line) that evaluates to True if and only if the product of any two numbers in the given list is greater than the sum of all three numbers. Note: the product of two numbers, x and y is x*y. Question 3 (List/table access) You are given a table,…arrow_forward
- C++ codearrow_forwardOverview In this assignment you will create user-defined functions OUTSIDE the main program and call those functions from INSIDE the main program. Instructions This assignment will require you to create functions in the program which the main procedure calls. Write a C++ program that Reads data from an input file. The data file should include 10 students. Each student should have Takes the data and computes student grades for an assignment by converting the raw score to a percentage given each student's score and the total points. Round the final score up to the nearest whole value using the ceil function in the <cmath> header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to compute and print the percentage as well as "Excellent" if the grade is greater than 90, "Well Done" if the grade is greater than…arrow_forwardC++ programming Chapter(s) Covered: Chapter 1-8 Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columnsshown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly. Each number 1 – 9must not be used more than once. So, if you were to add up thenumbers used, The sum of each row, each column and each diagonal all add upto the same number, Write a program that simulates a magic square using 3 onedimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magicsquare. The program asks the user to enter the values of the magicsquare row by row and informs the user if the grid is a magicsquare or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this…arrow_forward
- Average grades bar chart Write a python program grades.py that reads a file of assignment grades and draws a bar chart of the average grades for each assignment. Save the figure as grades.png in the current working directory. The format of a line in the file is: assignment_type grade Note that there is a single space between the assignment type and the grade. E.g. exam 92.80 Your program must contain the following functions: Function name Function description Function input(s) Function return value(s) get_grades() This function takes a file name as input and populates a dictionary containing the assignment types and grades. Filename string Dictionary of grades main() This function prompts for the grades file name. Next, it calls the functions get_grades(). Next, it draws the bar chart of the average grade for each assignment. Hint: You can use the mean function of the statistics module to calculate the average of a list. None None Use the starter…arrow_forwardAs parameters to functions, arrays are passed by value. Select one: O True O False gearrow_forwardProgram Description:in C language The project is a student management system which maintains student records in a simple text file. Your task is to write a program to save a list of students records in a FILE and then perform several operations on this FILE. Your program will ask user to choose the option from a menu. The 3 major function in menu are: ADD STUDENT FIND STUDENT PRINT LIST Exit How it Works The menu is handled by do while and switch statement. Sample output The Methods to be implemented are as follows: 1. ADDSTUDENT This method will add a new student to the file. It takes 3 parameters ( student name, id, and GPA). Your program must ask the user to enter the details of new students: Name, ID and GPA 2. FINDSTUDENT This method will search for a student with his/her id in the file. If the student is found it will print her/his record to the output. If the student is not found it will print “There is no record of this student in this system” 3. PRINTLIST This method will…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning