Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 16, Problem 10PC
Program Plan Intro
Two Dimensional Data
Program Plan:
- Include the required header files.
- Define the function getData(),
- Declare and initialize the variable.
- Loop executes until k is less than number. If yes,
- Read the index of the tourists from file.
- Store the tourists name into vector.
- Loop executes until k is less than number. If yes,
- Read the index of the tourists from file.
- Loop executes until j is less than numberDestinations. If yes,
- Read the destination from the file.
- Add the favorite destination for each person.
- Store the favorite destination for each person into another vector.
- Define the function indexOf(),
- Loop executes until the k is less than size of vector. If yes,
- Check whether the name is equal to vector name. If yes,
- Return the k value.
- Check whether the name is equal to vector name. If yes,
- Exit the function
- Loop executes until the k is less than size of vector. If yes,
- Define the “main()” function.
- Create object to open the file.
- Check for file existence. If yes,
- Display the file status.
- Declare the two vectors.
- Call getData() function retrieves data from the file and stores it into two vectors.
- Loop executes until k is size of tourists. If yes,
- Display the names of tourists
- Display the statement.
- Loop executes until true. If yes,
- Read the name of the tourist from user.
- Check name is equal to quit. If yes, exit the program.
- Call the indexOf() function returns the index of a string in a vector of strings.
- Check the index is equal to -1. If yes,
- Display the statement.
- Continue the program.
- Loop executes until the end of the vector. If yes,
- Display the statement.
- Increment iteration by 1.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Computer Science
Write a python program that reads the data file https://archive.ics.uci.edu/ml/machine-learning-databases/eventdetection/CalIt2.data and finds the total count of outflow and the total count of inflow. The attributes in the file are as follows:
1. Flow ID: 7 is out flow, 9 is in flow
2. Date: MM/DD/YY
3. Time: HH:MM:SS
4. Count: Number of counts reported for the previous half hour Rows: Each half hour time slice is represented by 2 rows: one row for the out flow during that time period (ID=7) and one row for the in flow during that time period (ID=9) Hint: # Importing the dataset dataset = pd.read_csv('CalIt2.data')
https://archive.ics.uci.edu/ml/machine-learning-databases/event-detection/CalIt2.data
this link should work.
Alert dont submit AI generated answer.
Given a text file containing the availability of food items, write a program that reads the information from the text file and outputs the available food items. The program first reads the name of the text file from the user. The program then reads the text file, stores the information into four separate arrays, and outputs the available food items in the following format: name (category) -- description
Assume the text file contains the category, name, description, and availability of at least one food item, separated by a tab character.
Ex: If the input of the program is:
food.txt
and the contents of food.txt are:
Sandwiches Ham sandwich Classic ham sandwich Available Sandwiches Chicken salad sandwich Chicken salad sandwich Not available Sandwiches Cheeseburger Classic cheeseburger Not available Salads Caesar salad Chunks of romaine heart lettuce dressed with lemon juice Available Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Not available Drinks Water…
Chapter 16 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 16.1 - Prob. 16.1CPCh. 16.1 - Prob. 16.2CPCh. 16.1 - Prob. 16.3CPCh. 16.1 - Prob. 16.4CPCh. 16.1 - Prob. 16.5CPCh. 16.2 - Prob. 16.6CPCh. 16.2 - The function int minPosition(int arr[ ], int size)...Ch. 16.2 - What must you be sure of when passing a class...Ch. 16.2 - Prob. 16.9CPCh. 16.4 - Prob. 16.10CP
Ch. 16.4 - In the following Rectangle class declaration, the...Ch. 16 - The line containing a throw statement is known as...Ch. 16 - Prob. 2RQECh. 16 - Prob. 3RQECh. 16 - Prob. 4RQECh. 16 - The beginning of a template is marked by a(n)...Ch. 16 - Prob. 6RQECh. 16 - A(n)______ container organizes data in a...Ch. 16 - Prob. 8RQECh. 16 - Prob. 9RQECh. 16 - Prob. 10RQECh. 16 - Write a function template that takes a generic...Ch. 16 - Write a function template that is capable of...Ch. 16 - Describe what will happen if you call the function...Ch. 16 - Prob. 14RQECh. 16 - Each of the following declarations or code...Ch. 16 - Prob. 16RQECh. 16 - String Bound Exceptions Write a class BCheckString...Ch. 16 - Prob. 2PCCh. 16 - Prob. 3PCCh. 16 - Sequence Accumulation Write n function T...Ch. 16 - Rotate Left The two sets of output below show the...Ch. 16 - Template Reversal Write a template function that...Ch. 16 - SimpleVector Modification Modify the SimpleVector...Ch. 16 - Prob. 8PCCh. 16 - Sortabl eVector Class Template Write a class...Ch. 16 - Prob. 10PCCh. 16 - Word Transformers Modification Modify Program...Ch. 16 - Prob. 12PC
Knowledge Booster
Similar questions
- Given a text file containing the availability of food items, write a program that reads the information from the text file and outputs the available food items. The program first reads the name of the text file from the user. The program then reads the text file, stores the information into four separate arrays, and outputs the available food items in the following format: name (category) -- description Assume the text file contains the category, name, description, and availability of at least one food item, separated by a tab character. Ex: If the input of the program is: food.txt and the contents of food.txt are: Sandwiches Ham sandwich Classic ham sandwich Available Sandwiches Chicken salad sandwich Chicken salad sandwich Not available Sandwiches Cheeseburger Classic cheeseburger Not available Salads Caesar salad Chunks of romaine heart lettuce dressed with lemon juice Available Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Not available Drinks Water…arrow_forwardI need help on my python assignmentarrow_forwardIn c language,using pointer and for loop Code level: Beginnersarrow_forward
- solve in pythonarrow_forwardCan you use Python programming language to to this question? Thanksarrow_forwardPython: if possible answers in one line of code def name_sort(staff): ''' Question 2 You are given a list of Georgia Tech staff members- each with a first and last name separated by a space, and need to sort them alphabetically by last name for a directory. However, the person who provided you the list did not proofread the records and accidentally misspelled some of the names. You can identify which ones have typos just by looking at the first letter of the first name. - First, sort the list alphabetically by the last name. - Remove any members whose first name starts with "Q" or "X". - Return the resulting list. Args: staff (list) Returns: list >>> name_sort(['Damon Williams', 'Xngel Cabrera', 'George Burdell', 'Brett Key', 'David Joyner', 'Qon Lowe']) ['George Burdell', 'David Joyner', 'Brett Key', 'Damon Williams'] ''' # print(name_sort(['Damon Williams', 'Xngel Cabrera', 'George Burdell', 'Brett…arrow_forward
- Computer Science (PYTHON) Once a transaction completes, update the quantity on hand for each item sold to a customer in the dictionary: Quantity = {101:2,102:5,103:8,104:2,105:8,106:4,107:6,108:3,109:2,110:10}arrow_forwardPart B - reading CSV files You will need a Python repl to solve part B. Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US government showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code The data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers. Your function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's value should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1). Important Hints: * You will really, really want to use the built-in csv…arrow_forwardProgramming Language BSL Purpose To design a small program using structured data. Expectations You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions. Failure to submit a .rkt file will result in a 0. You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0. You should only use the concepts that we have covered in class so far. Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment. You must follow all the steps of the design recipe when completing this assignment. Graded Exercises Exercise 1 Design a data definition for a mathematical expression. Your data definition should be able to handle the addition, subtraction, and multiplication of any two integers. You do not need to…arrow_forward
- Using binary search approach, write a python function named update_record, which takes the following inputs: 1: students_records – Nested List of Tuples. Each tuple of the list represents student's data. 2: ID – An ID of a student whose data has to be updated 3: record_title – type of data that has to be updated 4: data – A new data that should replace record_title data and update the record of students' data associated to specific ID. If ID is given as the data to be updated, then return a message that ID cannot be updated. If ID is not found in students_records, then return a message that Record not found. NOTE: The type of record_title input can be "ID", "Email", "Mid1" or "Mid2". Please use the same spelling for these types in your code, because the same have been used in test cases. Test cases are attached below: student_records = '[("aa02822", "ea02822", 80, 65),("ea02822", "ea02822@st.habib.edu.pk", 80, 65),("fa08877", "fa08877@st.habib.edu.pk", 66, 67),("gh04588",…arrow_forwardWrite every task in C++ programming language using arrays, array input/output and array operations. Task 1: Write a program that reads the characters from a text file. It counts total number of character and total number of vowels in the file.arrow_forwardPython Programmingarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning