/* Computer Science & Programming Jason M. Snouffer Wednesday, October 16, 2002 Lab 7 Problem 4 This program takes a text file and changes all the lower case letter to upper case. All the uppercase values to lower case Replaces + with spaces Test Suite: Input: Rowan+University's+Computer+Science +Program+Gains+Accreditation+ +October+2,+2001+ +Rowan+University's+Computer+Science+has +received+accreditation+from+the+Computer +Science+Accreditation+Commission+of+the +Computer+Science+Accreditation+Board. +Rowan's+program+is+one+of+only+171+computer +science+programs+currently+accredited+across+the +country+and+only+six+programs+accredited+in+the +state.+ +"For+the+students,+the+parents+of+students+and+the +prospective+employers+of+the+students,+the +accreditation+indicates+that+our+program+meets +rigorous+national+standards,+and+it+will+continue+to +improve+in+order+to+maintain+accreditation,"+said +Jianning+Xu,+chair+of+the+Computer+Science +department.+"The+accreditation+is+a+reflection+of +the+high+quality+work+that+Rowan+degrees+in +computer+science+represent."+ +Established+in+1990,+the+Computer+Science +Department+offers+both+a+major,+four-year +program+as+well+as+a+minor+program+in+computer +science.+The+department,+which+currently +educates+377+full-+and+part-time+undergraduate +computer+science+majors,+graduates +approximately+35+students+a+year.+The+study+of +computer+science+provides+graduates+with+a +foundation+for+working+in+and+adapting+to +changes+in+the+rapidly+developing+field+of +computers.+ +For+more+information+about+the+major,+visit +http://elvis.rowan.edu/compsci/.+ @ Output: rOWAN uNIVERSITY'S cOMPUTER sCIENCE pROGRAM gAINS aCCREDITATION oCTOBER 2, 2001 rOWAN uNIVERSITY'S cOMPUTER sCIENCE HAS RECEIVED ACCREDITATION FROM THE cOMPUTER sCIENCE aCCREDITATION cOMMISSION OF THE cOMPUTER sCIENCE aCCREDITATION bOARD. rOWAN'S PROGRAM IS ONE OF ONLY 171 COMPUTER SCIENCE PROGRAMS CURRENTLY ACCREDITED ACROSS THE COUNTRY AND ONLY SIX PROGRAMS ACCREDITED IN THE STATE. "fOR THE STUDENTS, THE PARENTS OF STUDENTS AND THE PROSPECTIVE EMPLOYERS OF THE STUDENTS, THE ACCREDITATION INDICATES THAT OUR PROGRAM MEETS RIGOROUS NATIONAL STANDARDS, AND IT WILL CONTINUE TO IMPROVE IN ORDER TO MAINTAIN ACCREDITATION," SAID jIANNING xU, CHAIR OF THE cOMPUTER sCIENCE DEPARTMENT. "tHE ACCREDITATION IS A REFLECTION OF THE HIGH QUALITY WORK THAT rOWAN DEGREES IN COMPUTER SCIENCE REPRESENT." eSTABLISHED IN 1990, THE cOMPUTER sCIENCE dEPARTMENT OFFERS BOTH A MAJOR, FOUR-YEAR PROGRAM AS WELL AS A MINOR PROGRAM IN COMPUTER SCIENCE. tHE DEPARTMENT, WHICH CURRENTLY EDUCATES 377 FULL- AND PART-TIME UNDERGRADUATE COMPUTER SCIENCE MAJORS, GRADUATES APPROXIMATELY 35 STUDENTS A YEAR. tHE STUDY OF COMPUTER SCIENCE PROVIDES GRADUATES WITH A FOUNDATION FOR WORKING IN AND ADAPTING TO CHANGES IN THE RAPIDLY DEVELOPING FIELD OF COMPUTERS. fOR MORE INFORMATION ABOUT THE MAJOR, VISIT HTTP://ELVIS.ROWAN.EDU/COMPSCI/. @ All of the sample inputs within this test suite were tested and performed as expected. */ #include #include #include using namespace std; /* This program is a simple demonstration of how to read and write * files in C++ using input and output streams. * * For now, don't worry about how this stuff works. All you need to * know, is that if you copy and paste everything except main in this * file, that you can write a main that uses these functions. * */ //----------------- open_output_file_stream --------------------- /* * This function returns an object of type ofstream that gives the * user a way to write to the file filename. If filename * is not a valid file, then this function halts the program using * the exit command. * * * pre: filename should be the name of a file in the same * folder as the program itself. * */ ofstream open_output_file_stream(char *filename); //----------------- open_input_file_stream --------------------- /* * This function returns an object of type ifstream that gives the * user a way to read from the file filename. If filename * is not a valid file, then this function halts the program using * the exit command. * * * pre: filename should be the name of a file in the same * folder as the program itself. * */ ifstream open_input_file_stream(char *filename); int main() { ifstream input = open_input_file_stream ("../Lab 7/sample2.txt"); ofstream output = open_output_file_stream ("../Lab 7/output.txt"); char letter, newletter; do { input >> letter; if(islower(letter)) { newletter=toupper(letter); output<open(filename); if (out->fail()) { cout << "ERROR: Couldn't open " << filename << ", halting program!\n"; exit (EXIT_FAILURE); } else { cout << "Successfully opened " << filename << "!" << endl; } // if we get to here, we successfully opened the file for writing return (*out); } //----------------- open_input_file_stream --------------------- /* * This function returns an object of type ifstream that gives the * user a way to read from the file filename. If filename * is not a valid file, then this function halts the program using * the exit command. * * * pre: filename should be the name of a file in the same * folder as the program itself. * */ ifstream open_input_file_stream(char *filename) { ifstream *in = new (ifstream); in->open(filename); if (in->fail()) { cout << "ERROR: Couldn't open " << filename << ", halting program!\n"; exit (EXIT_FAILURE); } else { cout << "Successfully opened " << filename << "!" << endl; } // if we get to here, we successfully opened the file for writing return (*in); }