C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
Question
Book Icon
Chapter 8.5, Problem 5E

(a)

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare object of ofstream.
  • Create a file named “gradeUpdate.dat” to write contents.
  • Use if statement with fail() method to check that the entered file name is available or not.
  • Read data from the program and write data to the file.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of this program is to create the “gradeUpdate.dat” file and to store the given data in the file.

(b)

Program Plan Intro

Program Plan:

  • Include library files for various operations.
  • Declare twoobjects ofofstream and ifstream.
  • Open both the given file “grades.dat” and “gradeUpdate.dat”.
  • Use if statement with fail() method to check that the file name is available or not.
  • Use arrays, for retrieving the data per row from the file to generate the student record.
  • Convert the string values from the arrays to the integer values for manipulations.
  • Calculate the total credits and GPA obtained by each student.
  • int main() function is used to perform all the task.
  • Display the calculated results to the user.

Program Description: The main purpose of this program is toupdate the “gradeUpdate.dat” file created in part (a ) by using the “gardes.dat” file created in the previous question.

Blurred answer
Students have asked these similar questions
(python) Write a function sum_file(f) that takes a filename f. Each line in f contains a single number. You should write to the last line in the file the sum of all the numbers written in the file.
(Write a C++ program) This homework is from our textbook page 459 # 16. The Dodgers recently won the World Series vs the Tampa Bay Rays.  Attached are two files: Teams.txt - This file contains a list of serveral Major League baseball teams in alphabetical order.  Each team is listed in the file has won the World Series at least once. WorldSeries Winners.txt - This file contains a chronological list of the World Series' winning teams from 1903-2020. (The first line of the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2020.  Note the World Series was not played in 1904 or 1994.) Write a program that displays the contents of the Teams.txt file on the screen and prompts the user to enter the name of one of the teams.  The program should then display the number of times that team has won the World Series in the time period from 1903 to 2020. In the program, 2 arrays are needed:  TeamList array and Winners array.   TeamList array will…
(Q. Write a program that will read a file from the user and writes its content in another file such that each line contains only 8 words. Coding language python  Don't use pointers and arrays keep the program as simple as possible (beginner's level) Paste the screenshots of full program with output) inputfile = input('Enter filename to read: ') outputfile = input('Enter filename to write: ') f = open(inputfile,'r') f1 = open(outputfile,'w') for lines in f:     f1.writelines(lines) f.close() f1.close() ***write comments on each line of the above written program and make changes in it with accordance to question if anything is wrong and also check if the underlined part of question is solved in program or not
Knowledge Booster
Background pattern image
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