Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
Question
Book Icon
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.
    • Exit the function
  • 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.

Blurred answer
Students 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)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning