Programming and Problem Solving With C++
Programming and Problem Solving With C++
6th Edition
ISBN: 9781449694265
Author: Nell Dale
Publisher: Jones & Bartlett Learning
bartleby

Videos

Question
Book Icon
Chapter 4, Problem 6PP
Program Plan Intro

Program Plan:

  • The file name is inserted in the string s .
  • The file is opened with file stream fs.
  • A Boolean variable prev is declared to check for a comma.
  • A while loop is used to go through the file.
  • Inside the loop, conditions are given to encounter the word after a comma.
  • The if condition will print the word before a comma.
  • The else if condition will print the word after a full stop.
  • The first else condition will print the word after a comma.
  • The second else will check for a comma.

Program Description:

To print the first word after the comma from the text file whose name is given by the user.

Blurred answer
Students have asked these similar questions
Write a C++ program that reads lines from a file until the end of file. The program should prompt the user for the file name to read from. The program should open the file for reading, and if the file cannot be opened, print the message “File couldn’t be opened”, followed by a space and the filename, and exit. The program should keep track of the number of lines, the number of non-blank lines, the number of words, and the number of integers read from the file.
Write a C program named toupper.c that reads the contents of a file, and writes to another file after changing all lowercase letters in the input file to uppercase.   The name of the input file and the output file are to be passed as  command line arguments. Assume there are only ASCII characters in the input file. The length of the input file is not known beforehand. So make sure your program keeps reading bytes until EOF is reached. Use the library function toupper to concert letters into uppercase.   Example: The program is run from the command line as follows; C:\>toupper.exe infile.txt outfile.txt Suppose the contents of the input file infile.txt is: AbcdefG The contents of the output file outfile.txt should be: ABCDEFG
You are required to write a C++ program that reads several hundreds of movie ratings from an input file, and output a list of Number of times rated (#Rated), sum of ratings (Total Ratings) and average ratings of the movies.The application program reads in several hundreds of movie ratings from an input file“Rating_list.txt”. Each line in the input file represents one review, indicating the title of the movie and a rating (between 0 and 5) separated by a space. Sample lines from the input file is shown below.The output must be formatted as shown below (see the columns and decimal places). In addition, the output must include the total number of unique movie titles and the total number of rating
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License