Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 6.2, Problem 19STE
Explanation of Solution
//Include the needed headers
#include <fstream>
#include <iostream>
//main() Method
int main( )
{
using namespace std;
//creating object for ifstream
ifstream ins;
//a handle for opening the input file
ins.open("list...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
For c++ please
3. Laramie Park District has files of participants in its summer and winter programs this year. Each
file is in participant ID number order and contains additional fields for first name, last name, age,
and class taken (for example, Beginning Swimming).
a. Design the logic for a program that merges the files for summer and winter programs to
create a list of the first and last names of all participants for the year in ID number order.
b. Modify the program so that if a participant has more than one record, the participant's ID
number and name are output only once.
c. Modify the program so that if a participant has more than one record, the ID number and
name are output only once along with a count of the total number of classes the participant
has taken.
7
Chapter 6 Solutions
Problem Solving with C++ (10th Edition)
Ch. 6.1 - Prob. 1STECh. 6.1 - Prob. 2STECh. 6.1 - Suppose that you are still writing the same...Ch. 6.1 - Prob. 4STECh. 6.1 - Prob. 5STECh. 6.1 - Prob. 6STECh. 6.1 - Suppose bla is an object, dobedo is a member...Ch. 6.1 - Prob. 8STECh. 6.1 - Prob. 9STECh. 6.1 - A program has read half of the lines in a file....
Ch. 6.1 - Prob. 11STECh. 6.2 - Prob. 12STECh. 6.2 - Prob. 13STECh. 6.2 - Prob. 14STECh. 6.2 - What output will be sent to the stuff.dat when the...Ch. 6.2 - Prob. 16STECh. 6.2 - In formatting output, the following flag constants...Ch. 6.2 - Here is a code segment that reads input from...Ch. 6.2 - Prob. 19STECh. 6.2 - Write the definition for a void function called...Ch. 6.2 - (This exercise is for those who have studied the...Ch. 6.3 - Suppose c is a variable of type char. What is the...Ch. 6.3 - Suppose c is a variable of type char. What is the...Ch. 6.3 - Prob. 24STECh. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Suppose that the program described in Self-Test...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Prob. 29STECh. 6.3 - Define a function called copyLine that takes one...Ch. 6.3 - Prob. 31STECh. 6.3 - (This exercise is for those who have studied the...Ch. 6.3 - (This exercise is for those who have studied the...Ch. 6.3 - Suppose ins is a file input stream that has been...Ch. 6.3 - Write the definition for a void function called...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Write some C++ code that will read a line of text...Ch. 6 - Write a program that will search a file of numbers...Ch. 6 - Write a program that takes its input from a file...Ch. 6 - a. Compute the median of a data file. The median...Ch. 6 - Write a program that takes its input from a file...Ch. 6 - Write a program that gives and takes advice on...Ch. 6 - Write a program that reads text from one file and...Ch. 6 - Prob. 7PCh. 6 - Write a program to generate personalized junk...Ch. 6 - Write a program to compute numeric grades for a...Ch. 6 - Enhance the program you wrote for Programming...Ch. 6 - Prob. 4PPCh. 6 - Write a program that will correct a C++ program...Ch. 6 - Write a program that allows the user to type in...Ch. 6 - This project is the same as Programming Project 6,...Ch. 6 - This program numbers the lines found in a text...Ch. 6 - Write a program that computes all of the following...Ch. 6 - The text file babynames2012.txt, which is included...Ch. 6 - To complete this problem you must have a computer...Ch. 6 - Write a program that prompts the user to input the...Ch. 6 - The following is an old word puzzle: Name a common...
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
- IN C++, TRUE OR FALSE : The statement delete p; deallocates the dynamic array that is pointed to by p. In the statement cin >> y;, y can only be an int or double variable. In an output statement, the newline character may be part of the string. The extraction operator (>>) skips whitespace characters when searching for the next data in the input stream.arrow_forwardWrite a Program in C Language.arrow_forwardDART LANGUAGEarrow_forward
- Please do this in Python: Write a program that allows the user to navigate lines of text in a file. The program should prompt the user for a filename, read the file and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line number range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the text associated with that number.arrow_forwardThe 2 pictures are the beginning of the lab. The below is for part 2. read_file(0, clear_file); // Read in a file with of unknown length, getting the length from the file read. clear_file is a string containing the path to the clear text file. This function returns a char array created with memory allocation. read_file(len, clear_file); // Where len > zero, reads len chars from a file. clear_file is a string containing the path to the clear text file. This function returns a char array created with memory allocation. write_file(0, key, key_file); // Writes a string to file until the \0 char is reached. key is the string of random chars and key_file is a string containing the path of the text file. write_file(len, cipher, cipher_file); // Where len > zero, writes len chars to a file. cipher is the cipher string of chars and cipher_file is a string containing the path of the text file. The menu in main() should look like: Encrypt a file: 1Decrypt a file: 2Exit:…arrow_forwardThe stream insertion operator << and the stream extraction operator >> are overloadedto handle all standard data types—including strings and memory addresses (stream insertion only)—and all user-defined data types T/Farrow_forward
- Question 2 Write a C program which creates two child alternatively and print it on screen. processes. One of the child processes must open data1.txt and fill it with 10 random Sample Run data files and read one data from each file integers (0-9). The other child process must $/question2 open data2.txt and fill it with 10 random PARENT) Child process ID: 5379 letters (a-z). In the meanwhile, parent must CHILD1] wrote: 6 2 8 6 7 3 3 1 8 4 to print both child processes' id's and wait for CHILD2] Wrote: f y nhjw xkpm to them to finish. Then, it must open both file. [PARENT] Child process ID: 5378 file. [PARENT] 6 f 2 y 8 n 6 h 7 j 3 w 3 x 1 k 8 p 4 marrow_forwardIn python, rite a recursive function, displayFiles, that expects a pathname as an argument. The path name can be either the name of a file or the name of a directory. If the pathname refers to a file, its filepath is displayed, followed by its contents, like so: File name: file_path Lorem ipsum dolor sit amet, consectetur adipiscing elit... Otherwise, if the pathname refers to a directory, the function is applied to each name in the directory, like so: Directory name: directory_path File name: file_path1 Lorem ipsum dolor sit amet... File name: file_path2 Lorem ipsum dolor sit amet... ... Test this function in a new program.arrow_forwardThe function print_last_line in python takes one parameter, fname, the name of a text file. The function should open the file for reading, read the lines of the file until it reaches the end, print out the last line in the file, report the number of lines contained in the file, and close the file. Hint: Use a for loop to iterate over the lines and accumulate the count. For example: Test Result print_last_line("wordlist1.txt") maudlin The file has 5 lines.arrow_forward
- Write a write_scores function that opens the file, and writes scores and names from lst_scores and lst_names into the file. An example function call is below. Make sure to handle a file error. Assume good input in both lists. Function name: write_scoresParameters: lst_scores, a list of ints; lst_names, a list of strings; file_name, a string Purpose: Writes the names and scores to the file name, with one name and one corresponding score per line.Example function call: (attached) After this code runs, the file final_grades.txt should read: Ayesha 96 Paolo 99 Ahmed 93 Anna 94arrow_forwardINSTRUCTIONS: Read the problem below and provide the correct code. Sample input and output are also given along with the template code to be used. The programming language is Python.arrow_forward2. Write a function addname( ) that takes two strings, a filename, memberList.txt, and person’s name as parameters and adds the new name to the end of the list. The function will write the new file as memberList.txt. If the name is already in the list, the name will not be added.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:Cengage
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