EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 4PA
Program Plan Intro
Implementation of a pretty printing program that indents the code in input file.
Program plan:
- Define a function named “main()” to get the file input containing the code and process it using various “if()” conditions.
- Use a “if()” condition to check whether the input file is available or not.
- Use a “while()” loop to iterate till the end of the file and add the input to the array.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you write a new code in C ++ language with the values I sent you, just like this output?
There are two files named group1.txt and group2.txt that contain course information and grades of each student for each class. I will calculate each course average for each group and show in simple bar graph. Use "*" and "#"characters for group1 and group2, respectively. I will see the number -999 at the end of each line in the input files. This value is used for line termination and you can use it to verify that you have arrived at the end of the line. The averages of each group should also be calculated and printed at the end of the file. All of the results will be printed to the file. There will be no screen output. Sample output is shown in Figure 1.
Group 1:
CSC 80 100 70 80 72 90 89 100 83 70 90 73 85 90 -999ENG 80 90 80 94 90 74 78 63 83 80 90 -999HIS 90 70 80 70 90 50 89 83 90 68 90 60 80 -999MTH 74 80 75 89 90 73 90 82 74 90 84 100 90 79 -999PHY 100 83 93 80 63 78 88…
Can you write a new code in C ++ language with the values I sent you, just like this output?
There are two files named group1.txt and group2.txt that contain course information and grades of each student for each class. I will calculate each course average for each group and show in simple bar graph. Use "*" and "#"characters for group1 and group2, respectively. I will see the number -999 at the end of each line in the input files. This value is used for line termination and you can use it to verify that you have arrived at the end of the line. The averages of each group should also be calculated and printed at the end of the file.
Group 1:
CSC 80 100 70 80 72 90 89 100 83 70 90 73 85 90 -999ENG 80 90 80 94 90 74 78 63 83 80 90 -999HIS 90 70 80 70 90 50 89 83 90 68 90 60 80 -999MTH 74 80 75 89 90 73 90 82 74 90 84 100 90 79 -999PHY 100 83 93 80 63 78 88 89 75 -999
Group 2:
CSC 90 75 90 75 80 89 100 60 80 70 80 -999ENG 80 80 70 68 70 78 80 90 90 76 -999HIS 100 80 80 70 90 76 88 90 90…
Given an array of integers, write a C++ code snippet ( a code snippet is a self-contained piece of source code that performs a specific task typically used for illustrative purposes such as the examples in the videos) that :
returns the smallest element in the array.
returns the sum of all the elements in the array.
swaps the first and the last element in the array.
Chapter 5 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Ch. 5 - Prob. 1ECh. 5 - Prob. 2ECh. 5 - Prob. 3ECh. 5 - Prob. 4ECh. 5 - Prob. 5ECh. 5 - Prob. 6ECh. 5 - Prob. 7ECh. 5 - Prob. 8ECh. 5 - Prob. 9ECh. 5 - Prob. 10E
Ch. 5 - Prob. 11ECh. 5 - Prob. 12ECh. 5 - Prob. 13ECh. 5 - Prob. 14ECh. 5 - Prob. 15ECh. 5 - Prob. 16ECh. 5 - Prob. 17ECh. 5 - Prob. 18ECh. 5 - Prob. 19ECh. 5 - Prob. 20ECh. 5 - Prob. 21ECh. 5 - Prob. 22ECh. 5 - Prob. 23ECh. 5 - Prob. 24ECh. 5 - Prob. 25ECh. 5 - Prob. 26ECh. 5 - Prob. 27ECh. 5 - Prob. 28ECh. 5 - Prob. 29ECh. 5 - Prob. 1PACh. 5 - Prob. 3PACh. 5 - Prob. 4PACh. 5 - Prob. 5PA
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
- The following project should be done in C++ language: Write a function (module) that reads the contents of a file named Char.txt (you will have to create this file on notepad or any other text editor and write a sentence of your choice. Your sentence should include upper case, lower case, and numbers. Keep in mind you need to submit this file as well) and determine the following: The number of uppercase letters in the file . The number of lowercase letters in the file The number of digits in the file The total number of characters in your sentence. Upon finishing the task, program will ask the user if they would like to read the same file again and the program will re-start (you need to utilize a loop to do so) should the user prompt the program with 'Y'. Prompts and Output Labels. There are no prompts-- nothing is read from standard keyboard, just from the file Character.txt. Each of the numbers calculated is displayed on a separate line on standard output, preceded by the following…arrow_forwardWrite a C++ program that reads the contents of (data.txt) file which contains 3- digit numbers, and then finds the number with the maximum digits summation and prints it with the summation on the screen. Example 1: data txt The number with maximum digits summation is 989 Digit's summation 26 455 657 121 356 909 957 989 459 789 878arrow_forwardWrite a C++ program that opens three files (i.e. s1.txt, s2.txt, and s3.txt) and reads the data of three students. Each file contains the student first name and last name separated by a space and the student grades in three subjects as double floating-point numbers on the next line. The program should output the data in table format such that the data of each student is displayed on one line. The data of the students is ordered in the table alphabatically according to their names. The last column in the table contains the average grade of each student. The last row in the table contains the maximum grade in each subject. Notice that the width of the first column in the table is 20 and its is aligned to the left. All remaining columns have width of 7 and their data is aligned to the right. Also Notice, that all the numbers in the table must be displayed with exactly two decimal digits. IMPORTANT NOTES . Do not add any cout statements except for the final outputs as shown in the sample…arrow_forward
- Write C++ code to read a list of integers from a file until the end of the file is reached. When the entire file has been read, print the sum of the numbers that were read. Include declarations for all variables that you use, including the file object, and be sure to open and close the file (you can make up the file name). Assume that the integers are each on a new line.arrow_forwardWAP in c++ that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel. [ i have already asked this question but u gave the wrong answer ...plz give correct answer i have to prepare for my exams ]arrow_forwardWrite a C++ Program using classes, functions (recursive and otherwise), arrays and other C++ commands where a user enters the name of a file and the program calculates the amount of vowels (a e.iou -lower case and A ELO,U - UPPER CASE, separately!), the letters y, Y, ñ, Ѹ and punctuation marks in the file. You can use the Loren Ipsum generator online for a test file: https://es.lipsum.com/arrow_forward
- Develop a C++ program that reads the student’s name and scores from the attached data file “students.txt” and store them in an array of Student struct objects, then calculate and display each student’s final grade based on the following criteria: midterm exam is counted for 25% of the final grade, final exam is counted for 25% of the final grade and average of 4 labs is counted for 50% of the final grade. The format of the attached data file “txt” is --- //student name // midterm exam score, final exam score // lab1 score, lab2 score, lab3 score, lab4 score Expected output on screen --- Define a new struct data type “Student” to represent a student record. Each student’s record should be read from the data file “txt” and stored in a variable of Student struct. Create an array of Student struct with size of 24, save all student struct records in this array. Define a function “calculateGrade(…)” which: Needs a Student struct record as parameter. Calculate this student’s final…arrow_forwardcreate a program in C++ that does the extraction and analysis described above except that the tasks shall be made somewhat simpler. The program shall read from a file "inputdata.txt" containing a name and exactly five values of floating point numbers per line in the file. The first line of the file shall contain the name of the person (first and last) that gathered the data i.e. Joe Jones. The second line of the file shall be the first row of data. Your program will process all the lines in the file as described below. As the program reads each row of data, it shall do two things: it shall keep a running sum of the values read for that row, and shall also write the average of that row to a file "averages.txt". The program will continue reading from the file until it reaches the end of the file. This will entail using a "while" loop and the eof() function that is talked about in Chapter 13 of the text book. The person's name is to be read in at one time using "getline" and stored under…arrow_forwardWAP in c++ that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel. [ plz give correct answer i have to prepare for my exams ]arrow_forward
- Write a program using C++ that allows you to write stats of a monster and save it to a file. Make sure the stats are in a structure. This program also allows you to open the file and read the stats of the monster. (Print what was read onto the screen -- put the values into a structure. If you put the info into the file via binary, you will need to read it via binary too.) Use the error stream (either cerr, clog, or stderr) to print out errors if the files do not open.arrow_forwardDevelop a C++ program that reads the student’s name and scores from the attached data file “students.txt” and store them in an array of Student struct objects, then calculate and display each student’s final grade based on the following criteria: midterm exam is counted for 25% of the final grade, final exam is counted for 25% of the final grade and average of 4 labs is counted for 50% of the final grade. The format of the attached data file “students.txt” is --- //student name // midterm exam score, final exam score // lab1 score, lab2 score, lab3 score, lab4 score Define a new struct data type “Student” to represent a student record. Each student’s record should be read from the data file “students.txt” and stored in a variable of Student struct. Create an array of Student struct with size of 24, save all student struct records in this array. Define a function “calculateGrade(…)” which: Needs a Student struct record as parameter. Calculate this student’s final grade…arrow_forwardIn C++, add movies and prices to an existing text file using STL iterators, containers , or algorithms. movies.txt with all possible movies that goes with the program above: The Adventures of a Babysitter $10 Barney $25 Larry the Car Man $15 Dora and the missing map $15 Ceasar and the Lunch Lady $10 Suzie and the Bad Kids $13.95 Please add it on in the existing file and not erase the existing data from the filearrow_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
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY