C++ Please Help Please #define _CRT_SECURE_NO_WARNINGS #include #include #includ
ID: 3767951 • Letter: C
Question
C++ Please Help Please
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
#include
using namespace std;
const int MAX_FILE = 1000;
//prototypes
int main ( int argc , char *argv [ ] )
{
ifstream fin;
ofstream fout;
char openfile [ MAX_FILE ];
char fontLine [ 500 ] = { 0 };
if ( argc != 3 )
{
cout << "Incorrect input, program4 data.in" << endl;
}
strcpy ( openfile , argv [ 1 ] );
fin.open ( openfile );
if ( !fin )
{
cout << "Unable to open the file: data.in" << endl;
fin.close ( );
return -1;
}
void read FontData ( char*fontName )
if stream fin_font;
char extention [ ] = { ".tnr" };
char fontNameAcc [ MAX ] = { '' };
int i = 0;
int j = 0;
char temp;
cout << font name << endl;
for ( i = 0; i < stlen ( fontname ); i++ )
{
fontname ( )
Your job is to write a program that helps to gure out how many units of toner it will take to print various strings of characters.
Required Functions
Your program must implement at least the following ve functions (with appropriate arguments):
// Get the point size from an input string int extractPointSize()
// Sort the "records" by cost void sortByCost()
// Use the font name to read the data file void readFontData()
// Use the font data and string to be printed int getTonerUsed()
// Print a message about how to use the program void printUsage()
2
Input
The main input le consists of a sequence of zero or more records. Each record consists of a line containing the name and point size of the font used, followed by a line of text. Each line of text is at most 1000 characters long. The name of the input le will be given as the rst command line argument. If the le name is not given on the command line, or if the le
1
cannot be opened, then your program should print an appropriate message and exit with a non-zero return code. There will be no more than 1000 records in the input le. You also be given a set of les containing the tables of toner usage for every possible 12 point font, as previously described. Each le name is in the format .tnr where is the name of a font, with all characters lower-case and with all space characters converted to underscore characters. For example the table for the 12 point Goober Extended" font will be stored in the goober_extended.tnr" le. The toner usage les consist of a series of pairs. Each pair consists of a character and an integer number of toner units required to print that character. The characters in each toner usage le are not in any particular order, and the order is di erent from one le to the next. Toner usage for any character not listed in the toner usage le must be assumed to be zero.
Sample Input
Misc-Crackling-medium-r-normal 12 This is a short line. misc-Futura Poster-light-r-normal 24 THIS IS A LONGER, MORE EXPENSIVE LINE. misc-cmr10-medium-r-normal 10 This is cheap.
Sample Output
Record: 3 Font: misc-cmr10-medium-r-normal Size: 10 Toner required: 2179 String: This is cheap.
Record: 1 Font: Misc-Crackling-medium-r-normal Size: 12 Toner required: 6868 String: This is a short line.
Record: 2 Font: misc-Futura Poster-light-r-normal Size: 24 Toner required: 16880 String: THIS IS A LONGER, MORE EXPENSIVE LINE.
Explanation / Answer
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.