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
Two data files are required to evaluate a multiple-choice examination. The first file (booklet.dat) (memo) contains the correct answers. The total number of questions is 50. A sample file is given below:
ACBAADDBCBDDAACDBACCABDCABCCBDDABCACABABABCBDBAABD
The second file (answer.dat) contains the students’ answers. Each line has one student record that contains the following information:
The student’s answers (a total of 50 answers): each answer can be A, B, C, D or * (to represent no answer). There are no blanks between answers.
Student ID
Student name
A sample file is given below:
AACCBDBC*DBCBDAAABDBCBDBAA*BCBDD*BABDBCDAABDCBDBDA 6555 MAHMUT
CBBDBC*BDBDBDBABABABBBBBABBABBBBD*BBBCBBDBABBBDC** 6448 SINAN
ACB*ADDBCBDDAACDBACCABDCABCCBDDABCACABABABCBDBAABD 6559 CAGIL
Write a C++ program that counts the total number of correct answers by each student and outputs this information to another file called report.dat. In this file, the student’s IDs, names and the scores must be given. Each…
İn C language
JAVA PROGRAM
(Create large dataset) Create a data file with 500 lines. Each line in the file consists of a faculty member’s first name, last name, rank, and salary.
The faculty member’s first name and last name for the ith line are FirstNamei and LastNamei. The rank is randomly generated as assistant, associate, and full.
The salary is randomly generated as a number with two digits after the decimal point. The salary for an assistant professor should be in the range from 50,000 to 80,000, for associate professor from 60,000 to 110,000, and for full professor from 75,000 to 130,000. Save the file in Salary.txt.
Here are some sample data:
FirstName1 LastName1 assistant 60055.95
FirstName2 LastName2 associate 81112.45
. . .
FirstName500 LastName500 full 92255.21
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
- 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.arrow_forwardAn array is a sequence of data items that are of the same type, that can be indexed, and that are stored contiguously. Typically,an array is called a data structure used to represent a large number of homogeneous values. The elements of an array are accessedby the use of subscripts. Subscripts start from zero and runs until less than the size of the array. Arrays of all types are possible,including multi-dimensional arrays. Strings are just arrays of characters terminated by a special character called the null character.A typical array declaration allocates memory starting from a base address. The array name is in effect a constant pointer to thismemory address.a) Write a complete C program that demonstrates the usage of character strings. The program should declare an emptycharacter array of specific size, and then ask user to enter a string to be stored in the array using a scanf function. Theprogram should finally display the string entered to the screen for checking if the…arrow_forwardDescriptionWrite a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The date in the output file will be nearly the same as the data in the input file except that you will print the names as last-name, first-name; each quiz score, and there will be one additional number at the end of each line:the average of the student's ten quiz scores.Both files are parameters. You can access the name of the input file with argv[1]. and the name of the output file with argv[2].The output file must be formatted as described below: 1. First and last names…arrow_forward
- 3. Let us consider the file with employees: title Mechanics Librarian Gardener name Peter Norbert ID 120 150 170 age 30 23 35 salary 12000 11000 10000 Kai Please do the following: a. create a data type (record) that contains the six(6) data fields b. print the record c. store it d. update the salary e. scan the record according to their salary f. print the data with sorting on age Group Jo, George Ann, Eli Mary, Terryarrow_forwardHow do I do this using pythonarrow_forwardA bank’s customer records are to be stored in a file and read into a set of arrays sothat a customer’s record can be accessed randomly by account number. Create the file byentering five customer records, with each record consisting of an integer account number(starting with account number 1000), a first name (maximum of 10 characters), a last name(maximum of 15 characters), and a double-precision number for the account balance.After the file is created, write a C++ program that requests a user-input account number anddisplays the corresponding name and account balance from the file. (Hint: Read the data in thefile into an array, and then search the array for the account number.)arrow_forward
- One of the things discussed in this chapter is the sorting of data. Imagine that a large medical center hires you to write a program that displays a list of potential organ recipients. The hospital's transplant team will consult this list if they have an organ available for transplant. The hospital administrators have instructed you to sort potential recipients by last name and display them in alphabetical order. If more than 10 patients are waiting for a particular organ, the first 10 patients will be displayed; a doctor can either select one or move on to view the next 10 patients. You are concerned that this program will unfairly select patients whose last names begin near the front of the alphabet. It's critical that the hospital has a program written quickly, as the hospital currently has no method of going through potential organ recipients. Based on this, answer the following questions in detail: Would you write and install the program? If yes, would you change anything about…arrow_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_forwardComputer 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_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