STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
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
Problem: • Assume that we have a matrix that stored inside a file and it contains monthly salary of each employee of a company. The matrix column starts from month 1 to 12, and for the rows you can enter data for 6 employees minimum. • The output of the program must be the annual salary of each employee of the company.
DescriptionWrite 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…
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…

Chapter 16 Solutions

STARTING OUT WITH C++ MPL

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