辅导PIC 10B、program编程辅导、讲解c/c++程序 辅导Web开发|辅导Web开发
- 首页 >> Matlab编程 PIC 10B Homework 3 Due Wednesday, Feb 17
Problem 1:
Using good coding practices, write a program that compares the contents of two “.txt” files
and then saves the properties of the files in another “Properties.txt” file. The properties of
the each file should include the name of the file, the number of characters, the number of
words, and a sentence stating if one file has more lines than the other or the same amount
of lines.
Your program should prompt the user for the name of the files. Use operator overloading
to write functions that compare both files by the amount of lines such that ( file1 >
file2 ) returns true if file1 contains more lines than file2 and false otherwise. Similarly
( file1 == file2 ) returns true if the files contain the same amount of lines.
Figure 1 shows a sample output for the given file1 and file2.
Figure 1: Homework 3 sample console, input files “JFMAbstract.txt” and “PhysicaDAbstract”,
and resulting output file “Properties.txt”
Due Wednesday, Feb 17 Homework 3 PIC 10B
Good Coding Practices:
❼ think about cross-platform. Don’t use Windows or Mac only commands. For example,
pause == cin.get() twice, write many \n vs. system(clear) or system(’cls).
❼ passing objects by reference & or const & when possible
❼ using field initializer list when possible in all constructors
Instructions for submission:
❼ Name your filse exactly hw3.cpp, textfile.h and textfile.cpp.
❼ You may not use #include "stdafx.h".
❼ Add code description in the comment at the beginning of the file.
A sample description may look like:
/*
PIC 10B 2A, Homework 1
Purpose: Tic-tac-toe game
Author: Hanqin Cai
Date: 10/10/2019
*/
❼ Submit your header files and source codes to CCLE in separate files. Only .h and .cpp
files should be uploaded.
Problem 1:
Using good coding practices, write a program that compares the contents of two “.txt” files
and then saves the properties of the files in another “Properties.txt” file. The properties of
the each file should include the name of the file, the number of characters, the number of
words, and a sentence stating if one file has more lines than the other or the same amount
of lines.
Your program should prompt the user for the name of the files. Use operator overloading
to write functions that compare both files by the amount of lines such that ( file1 >
file2 ) returns true if file1 contains more lines than file2 and false otherwise. Similarly
( file1 == file2 ) returns true if the files contain the same amount of lines.
Figure 1 shows a sample output for the given file1 and file2.
Figure 1: Homework 3 sample console, input files “JFMAbstract.txt” and “PhysicaDAbstract”,
and resulting output file “Properties.txt”
Due Wednesday, Feb 17 Homework 3 PIC 10B
Good Coding Practices:
❼ think about cross-platform. Don’t use Windows or Mac only commands. For example,
pause == cin.get() twice, write many \n vs. system(clear) or system(’cls).
❼ passing objects by reference & or const & when possible
❼ using field initializer list when possible in all constructors
Instructions for submission:
❼ Name your filse exactly hw3.cpp, textfile.h and textfile.cpp.
❼ You may not use #include "stdafx.h".
❼ Add code description in the comment at the beginning of the file.
A sample description may look like:
/*
PIC 10B 2A, Homework 1
Purpose: Tic-tac-toe game
Author: Hanqin Cai
Date: 10/10/2019
*/
❼ Submit your header files and source codes to CCLE in separate files. Only .h and .cpp
files should be uploaded.