Write a
cin << |
with the corrected version
cin >> |
and each (incorrect) occurrence of
cout >> |
with the corrected version
cout << |
For an easier version, assume that there is always exactly one blank space between any occurrence of cin and a following <<, and similarly assume that there is always exactly one blank space between each occurrence of cout and a following >>.
For a harder version, allow for the possibility that there may be any number of blanks, even zero blanks, between cin and << and between cout and >>. In this harder case, the replacement corrected version has only one blank between the cin or cout and the following operator. The program to be corrected is in one file and the corrected version is output to a second file. Your program should define a function that is called with the input- and output-file streams as arguments.
If this is being done as a class assignment, obtain the file names from your instructor and ask your instructor whether you should do the easier version or the harder version.
(Hint: Even if you are doing the harder version, you will probably find it easier and quicker to first do the easier version and then modify your program so that it performs the harder task.)
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: Early Objects (6th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with C++: Early Objects (9th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Concepts Of Programming Languages
- Note: Please answer in C++ Programming language. During Eid, it is a tradition for every father to give his children money to spend on entertainment. Chef has N coins; denote the value of the coin i by vi. Since today is Eid, Chef gives one coin to each of his two children. He wants the absolute value of the difference between the values of the coins given to the two children to be as small as possible to be as fair as possible. Help the chef by telling him the minimum possible difference between the values of the coins given to the two children. Of course, the chef cannot give the same coin to both children. Possible input 1 3 142 Required Output 1arrow_forward1arrow_forwardin c++ In this exercise, we will read in a data file of employees (file is furnished to you, “employee.dat”): Employee SSN Employee Last Name Employee First Name Hours Worked Pay Per Hour Personal Income Tax Rate You assignment’s logic is to: Read in the records from the file, Pass the Hours Worked, Pay Per Hour, Personal Income Tax Rate to a single function to determine: Whether or not overtime pay is computed (anything over 40 hours is overtime at 1.5 times the regular pay). Compute any overtime pay at 1.5 times pay rate Compute the regular pay at regular hours (40 hours or less) Compute the gross pay (Regular Pay plus any overtime pay) Compute the personal income taxes withheld Compute Net Pay (gross pay minus personal income taxes withheld) Pass ALL these values BACK to the main calling routine from this one function. Display: the Employee SSN, Last Name, First Name, Total Hours, Regular Hours, Overtime Hours (if any), Pay Per Hour, Personal Income Tax Rate, Regular Pay,…arrow_forward
- Develop a substring operator using operator() in C++. The arguments should be the starting position for the substring and the length of the substring. The result should be a copy of the substring starting at the given position within our own data and ending at most the given length from the start. For example: Object's Value Operator Call Resulting Object's Value "bob wuz here" obj(0,4) "bob " "bob wuz here" obj(8,14) "here" (ran out of characters) "bob wuz here" obj(14,4) "" (nothing there) "bob wuz here" obj(4,1) "w" If the start position doesn't exist, send back an empty string (as we've defined). If there aren't 'length' characters left in our string after the given start position, return what we do have. Don't forget to write a test application to show that your operator works. (Perhaps you could modify the existing String test app?)arrow_forwardWrite a C++ program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. **DO NOT USE AN ARRAY OR GLOBAL VARIABLES!!!*** YOU MUST USE THE STATED FUNCTIONS. AND INPUT VALIDATION. For FULL CREDIT DISPLAY THE LOWEST SCORE WITH GOOD OUTPUT DESCRIPTION you MUST USE function prototyping.. DO NOT ACCEPT SCORES LESS THAN 0 OR GREATER THAN…arrow_forwardA parameter in a C++ function is passed by reference. Which of following statement is true?I. The reference of the real parameter is passed to the formal parameter; II. Changing the value of the formal parameter in the function will not change the real parameter; III. Changing the value of the formal parameter in the function will change the real parameter as well. Question options: a. I only b. II only c. I and II only d. I and III only Consider the following expression of integer operation in C++: int m = 15%6;int n = 15/6; What are the values of m and n? Question options: a. 3 2.5 b. 3 2 c. 2 2.5 d. 2.5 2.5 Consider an integer array a of length n with indexing starting at 0, where n is a positive integer. If the elements of the array a are to be written out in reverse order,…arrow_forward
- Please Answer in C++ only A Rajesh teaches a cooking class. The course is attended by NN students, numbered 11 to NN. The cook must participate in the presence before each class, i.e. call out the names of the students one by one and indicate which students are present. Each student has a first and last name. To save time, Rajesh only wants to call up students' first names. However, if there are multiple students with the same first name, the Rajesh must call out the full names (first and last names) of all those students. For any student who does not share a first name with any other student, the cook can still only call that student's first name. Help the Rajesh decide for each student whether to call that student's full name or just their first name. Input 1 1 hasan jaddouh Output hasanarrow_forwardGive theory as solution like background theory, what concepts will apply in this questions and theory in c++ language. Do not give source code just give theory.arrow_forwardOnly in C++arrow_forward
- Write a program in C++ to help Buddy (the sheepdog) calculate the average age of all his sheep. Theprogram will accept as many ages as Buddy needs to input. The program should help Buddyminimize input errors by error-checking the age for him (everybody knows the maximum age forcartoon sheep is 9 years old). When Buddy’s sheep start to get old, he needs to breed moresheep. So, the code should also let Buddy know if the average age indicates if his sheep are aging,young, or middle-aged based on the chart below: average Sheep Age Population is… <= 3 Young 4 - 6 Middle-aged > 6 Agingarrow_forwardWrite a C++ program that: The first function is a default constructor which initializes sum and count to zeroarrow_forward4arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning