C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(C ONLY) The program expects the name of an input
file and an output file to be given by the user. If the
user does not input any names, default file names
should be used, such as input.txt and output.txt.
The input files have lines which look like this: 3
Tester College; 1909 33001 The first number
represents the rank; it is followed by the school
name, year founded, and approximate number of
students. Read the list of colleges into an array of
structures. You may assume that the maximum size
of a college name string is 64. The program should
use either the insertion sort algorithm or the
selection sort algorithm to sort the array in
descending order by rank. Display any k consecutive
schools requested by the user. For instance, if the
user enters 12, the program displays the first 2
schools in a readable format of your choice. If the
user enters 15, the program displays the first five
schools, if the user enters 2 7, display 7 schools
beginning with the one at index 1 (2 - 1), and so…
(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…
Chapter 8 Solutions
C++ for Engineers and Scientists
Ch. 8.1 - Prob. 1ECh. 8.1 - (Practice) a. Write a set of two statements...Ch. 8.1 - Prob. 3ECh. 8.1 - Prob. 4ECh. 8.1 - Prob. 5ECh. 8.1 - Prob. 8ECh. 8.1 - Prob. 9ECh. 8.1 - Prob. 10ECh. 8.2 - Prob. 1ECh. 8.2 - (Practice and modify) a. Enter and run Program...
Ch. 8.2 - (Practice and modify) a. Write a C++ program that...Ch. 8.2 - (Practice) Determine the OS command or procedure...Ch. 8.2 - Prob. 5ECh. 8.2 - (Data processing) a. Write a C++ program that...Ch. 8.2 - Prob. 7ECh. 8.2 - Prob. 8ECh. 8.2 - Prob. 9ECh. 8.3 - Prob. 1ECh. 8.3 - Prob. 2ECh. 8.3 - Prob. 3ECh. 8.3 - Prob. 4ECh. 8.3 - Prob. 5ECh. 8.3 - Prob. 6ECh. 8.4 - Prob. 1ECh. 8.4 - Prob. 2ECh. 8.4 - Prob. 3ECh. 8.4 - Prob. 4ECh. 8.5 - (Practice) Write a C++ program to create the...Ch. 8.5 - Prob. 2ECh. 8.5 - Prob. 3ECh. 8.5 - Prob. 4ECh. 8.5 - Prob. 5ECh. 8 - Prob. 1PPCh. 8 - (Data processing) a. Store the following data in a...Ch. 8 - (Data processing) Write a C++ program that allows...Ch. 8 - (Data processing) Write a C++ program that permits...Ch. 8 - (Data processing) Write a C++ program that reads...Ch. 8 - (Data processing) Write a C++ program that reads...Ch. 8 - Prob. 7PPCh. 8 - (Data processing) A bank’s customer records are to...Ch. 8 - (Inventory) Create an ASCII file with the...
Knowledge Booster
Similar questions
- (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 notarrow_forwardI need help with this: (Address book) Write a program that stores, retrieves, adds, and updates addresses as shown in Figure 17.20. Use a fixed-length string for storing each attribute in the address. Use random access file for reading and writing an address. Assume that the size of name, street, city, and zip is 32, 32, 20, 2, 5 chars, respectively.arrow_forward(C Language) Given a set of text files containing synonyms for different words, complete the main program to output the synonyms for a specific word. Each text file contains synonyms for the word specified in the file’s name, and the synonyms within the file are grouped according to the synonyms' first letters, separated by an '*'. The program reads a word and a letter from the user and opens the text file associated with the input word. The program then stores the contents of the text file into a two-dimensional array of char* predefined in the program. Finally the program searches the array and outputs all the synonyms that begin with the input letter, one synonym per line, or a message if no synonyms that begin with the input letter are found.arrow_forward
- Please explain what to do and in what program. Write a program that can provide basic calculator functionality in asm. (calculator.s) Write a C file (calculator.cpp) that uses the functions available in calculator.s (bonus for writing all four, addition, subtraction, division, mulitplication)arrow_forward(Class Average: Reading Student Records from a CSV File) Use Python Use the csv module to read the grades.csv file from the previous exercise (exercise 9.3). Display the data in tabular format, including an additional column showing each student’s average to the right of that student’s three exam grades and an additional row showing the class average on each exam below that exam’s column. This is exercise 9.3 # Importing csv moduleimport csv# empty list to store datadata = []columns = ["firstname", "lastname", "grade1", "grade2", "grade3"]filename = "grades.csv"for i in range(3):firstname = input("Enter First Name : ")lastname = input("Enter Last Name : ")grade1 = float(input("Enter Grade 1 : "))grade2 = float(input("Enter Grade 2 : "))grade3 = float(input("Enter Grade 3 : "))data.append([firstname, lastname, grade1, grade2, grade3])print()# write data and columns as csv filewith open(filename, 'w') as csvfile:# creating a csv writer objectcsvwriter = csv.writer(csvfile)# writing the…arrow_forwardDO NOT WRITE MAIN! Only write the function. A 50% minimum deduction will be made if main is included. No libraries or comments should be specified. (OP4) Write a function to prompt the user for the filename, open the file, and verify that it opened. If the file does not open, an error message should be printed and the user re-prompted. The function should use the string passed in for the prompt string. The function should not return until the file is open. The function prototype: void openInputFile( ifstream &, string ); ifstream& - the stream to be opened. string - the prompt to be written out to the user. Use this string when prompting the user.arrow_forward
- (C Language) Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space.arrow_forwardInstructions(C++) Write a program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges:0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200.Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189arrow_forwardExercise 1. (Spell Checker) Write a program spell_checker.py that accepts words from standard input; looks up each word in the file data/misspellings.txt that maps misspelled words to their correct spellings; and if it exists (ie, is misspelled), writes the word to standard output along with the correct spelling. >- "/workspace/project6 $ python3 spell_checker.py Try nto to become a man of sucess but rather try to become man of value. * Albert Einstein nto -> not sucess -> success E spell.checker.py from instream import InStream from symboltable import SymbolTable import stdio # Entry point. def main (): # Set inStream to an input stream built from the file 'data/misspellings.txt'. # Set lines to the list of lines read from inStream. .. # Set misspellings to a new symbol table object. .. for in ...: # For each line (of the form 'misspelling correction ') in lines... # Set tokens to the list obtained by splitting line using the split () method from str. # Insert the pair tokens…arrow_forward
- (DONT USE STRUCTURE... USE CLASSES) Write a C++ program which takes multiple Employees information (records) as inputs from the user and save them on a file using class. Writing in file should be done using setters. Perform following operations on the data saved in the file:• Read data from file• Search an employee’s information in the file• Count the number of employees having salary more than 50,000.arrow_forward(Intro to Python) Assume there is a file called numbers.txt (in the current working directory) with unknown number of integer values on each line. Write a program to read the numbers from the file, add them and then display the total. Use try-except clause to handle errors associated with working with files. This should work for any number of values in the file. If the file does not exist, it should not throw a runtime error. Sample output is, Read 6 numbers They are 5 7 8 3 100 14 Their total is 137arrow_forward(IN PYTHON) Problem 1 Write a function word_count() that performs the following actions: Opens a file called “novel.txt”. You can assume that the file exists and is located in the same directory as your code file. Reads in the contents of the file, and stores it in a variable called text. Uses the split() function to obtain a list containing all of the individual words in text. For details on how to use split(), you can consult this site: https://www.w3schools.com/python/ref_string_split.asp For this question, assume that all words will be separated by spaces. Returns the number of words in the lisarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education